Performance of Comparision of Boolean using = sign over using NOT function
Whether using
IF Approved? = TRUE THEN 1 ELSE 0
is good or optimizing the formula as
IF Approved? THEN 1 ELSE 0
where "Approved?" is a BOOLEAN format line item.
Same goes for,
IF Approved? = FALSE THEN 1 ELSE 0
IF NOT Approved? THEN 1 ELSE 0
Please advise to optimize performance of the model.
Answers
-
Hi @Pranjal
Below 2 are optimized way of coding
IF Approved? THEN 1 ELSE 0
IF NOT Approved? THEN 1 ELSE 0
the reason is because you dont need to tell a condition =true or false, since the if else condition is already taking logic.
please find article which will give you right approach of optimization for similar queries : https://community.anaplan.com/t5/Best-Practices/Formula-structure-for-performance/ta-p/33177
Thanks,
Manjunath2 -
The other thing to consider with IF loops (and calcs in general) is the concept of an early exit.
Your example is pretty straight forward, but you should try to write your calculations in a way where the most likely occurence is the earliest part of your calculation. Otherwise, the calculation engine has to run through the entire calculation until it either reaches the end, or finds a valid case.
E.g. If there's more occurences of 'Approved' instances, you'd write IF Approved THEN X ELSE Y. Otherwise you'd write it the other way around using IF NOT Approved ...
As I noted, this is more relevant for longer calculations, but you should apply this concept as a best practice where possible.
0