I have a For Each Row function working on a data table. It goes through a series of If statements evaluating values in some of the columns and then based on the findings it assigns a value to a :Correct_Process column.
Currently I have it setup like this.
For Each Row(
dt,
If( :Module == "M05" & :Measurement == "Conductivity",
If(:Actual > m5_cond_hi | :Actual < m5_cond_low,
:Correct_Process = "Incorrect",
:Correct_Process = "Correct"
);
If( splits_detected == 1 & Contains( col_name_list, "PMC_FreeForm" ),
If( :PMC_FreeForm == "DI" | Contains(:PMC_FreeForm, "Mod 5 pump off"),
If( :Actual != 0,
:Correct_Process = "Incorrect",
:Correct_Process = "Correct"
);
);
);
If( splits_detected == 1 & Contains( col_name_list, "CPMC_Conductivity" ),
num_cond = Num(:CPMC_Conductivity);
lim_hi = num_cond + 0.6;
lim_low = num_cond - 0.6;
If( :Actual > lim_hi | :Actual < lim_low,
show("Evaluated Incorrect");
:Correct_Process = "Incorrect",
show("Evaluated Correct");
:Correct_Process = "Correct"
);
);
When I run the script, if the value of :CPMC_Conductivity is "13.2" and the :Actual is 13.5, the :Correct_Process column is still assigned a value of "Incorrect". Interestingly, the log shows "Evaluated Correct" due to the show() statement when I would expect it to which means the If statements are being evaluated correctly, but the :Correct_Process is not assigned "Correct".
I am assuming its because I am assigning the :Correct_Process column by default with the first nested If statement then trying to overwrite with a more specific check in the third nested if statement. But I have similar checks within this group after this one that seem to be able to successfully overwrite in other conditions (such as the second nested if statement) so I am wondering what I am missing here.