Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
DataHound
Contributor II
Contributor II

IF Statement Performance

Hello all, 

I am currently troubleshooting my Apps performance issues. I have isolated it to a variable near the end of my process in determining a value to display in a table. There are multiple variables that feed into the end variable, with their own sets of IF statements.  The variables below are calculated results, essentially an indicator. If criteria are met, then a '1' is displayed, else nothing. It is from this that I am determining the final value to be displayed in the table. The issue is that this IF statement seems to really impact performance. Is there a better way to structure an IF statement? Can MATCH be used with calculated results? 

 

if(($(Criteria_1_Indicator)) = '1' and ($(Criteria_2_Indicator)) = '1','Both',
if(($(Criteria_1_Indicator)) = '1' and ($(Criteria_2_Indicator)) = '0','Criteria_1',
if(($(Criteria_1_Indicator)) = '0' and ($(Criteria_2_Indicator)) = '1','Criteria_2',
if(($(Criteria_1_Indicator)) = '0' and ($(Criteria_2_Indicator) = '0','Not Eligible',))))

 

 

Thanks!

 

Labels (1)
1 Solution

Accepted Solutions
Or
MVP
MVP

Perhaps:

Pick(1+($(Criteria_1_Indicator)*2) + $(Criteria_2_Indicator),'Not Eligible','Criteria_2','Criteria_1','Both') would work here? You could also do this in any number of other ways. Note that if the values are strings rather than numbers, you might be better off doing $(Criteria_1_Indicator) & $(Criteria_1_Indicator) and then pick/match the values 11, 10, 01, 00 instead of the numeric approach I used to keep it to a single formula.

View solution in original post

4 Replies
Or
MVP
MVP

Perhaps:

Pick(1+($(Criteria_1_Indicator)*2) + $(Criteria_2_Indicator),'Not Eligible','Criteria_2','Criteria_1','Both') would work here? You could also do this in any number of other ways. Note that if the values are strings rather than numbers, you might be better off doing $(Criteria_1_Indicator) & $(Criteria_1_Indicator) and then pick/match the values 11, 10, 01, 00 instead of the numeric approach I used to keep it to a single formula.

DataHound
Contributor II
Contributor II
Author

Thank you Or. That is a good idea.

I am going to give that a try. My suspicion is that the IFs are causing too many calculations or taking up too many resources. 

Or
MVP
MVP

In an if() statement, all branches are evaluated every time, so they do tend to cause performance issues. No idea if that's the actual case for you since your logic is hidden behind those variables.

Good luck!

DataHound
Contributor II
Contributor II
Author

Thank you very much, Or! This is a significant performance boost. There is a significant amount of logic behind the variables, and you're right, it must have been recalculating all of it each time.