Forum Discussion

Carina's avatar
Carina
Qrew Member
10 days ago

Upsert based on Condition

Hi All,

I have three tables. First is basic information, where people are marked as type A, B, or C.

Second is the question bank table, containing all the questions for them. There are two columns for weight. If they are type A or B, they will see the column "weight - A or B", but if they are type C, they see the column "weight - C"

Every time I create a new person record in the first table, I want to pull the questions and corresponding weight from the question bank to another table. I have created a pipeline (search records - add a bulk upsert row) to pull all the questions, but when it comes to the weight, how could I pull the corresponding weight based on their type? Thanks!

 

1 Reply

  • Mez's avatar
    Mez
    Qrew Captain

    Sounds like you could use a simple jinja If condition inside your weight field within the add bulk upsert row provided that in your Search step you've included both weight columns. To switch to code mode click on "</>" and then insert your code. 

    * assumes your step A is triggered when a new person is created, and your field names are most likely different from below, so adjust these as necessary:

    {% If a.person_type == "C" %}
    {{ b.weight_c }}
    {% else %}
    {{ b.weight_a_or_b }}
    {% endif %}