Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
maxsheva
Creator II
Creator II

IF calculation difference

Hi Qlik Guru,

Please advise whether any difference between two scenarios of IF use?

1. $(=IF(ConditionField='True',sum,max))(Measure1)

Expectation is only one calculation per chart

2. IF(ConditionField='True', sum(Measure1), max(Measure1))

Expectation is calculation per each row.


Could the first scenario work faster and calculates 'IF' only once per chart?

Or will it be calculated per each row anyway?

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I  think your example may be missing quotes around 'sum' and 'max'.

In any case, #1 should be faster.  it will still calculate per row, but it will only calculate one aggregation -- sum or max.

#2 will always calculate both sum and max but only display one result.

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

View solution in original post

5 Replies
ujjwalraja
Contributor III
Contributor III

The first scenario will calculate only when there is a selection in any field.

The second scenario is as per expectation.

For faster calculation, you can use Set Analysis.

maxsheva
Creator II
Creator II
Author

Thanks for reply Ujjwal but what do you mean "will calculate only when there is a selection in any field"?

In scenario1 when ConditionField meet 'True' value will it start to calculate per each row?

I suppose formula is checking by row in both cases doesn't matter what is selection is in ConditionField.


QlikView Performance Leaders could you help with this formula behavior?

marcus_sommer‌, gwassenaar, bbt‌, pcammaert‌, rwunderlich‌, colin_albert


Thank you for your time!

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Does #1 actually return something?  It looks invalid. 

-Rob

maxsheva
Creator II
Creator II
Author


In case when ConditionField equals 'True' the expression returns sum(Measure1)

It is working on practice.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I  think your example may be missing quotes around 'sum' and 'max'.

In any case, #1 should be faster.  it will still calculate per row, but it will only calculate one aggregation -- sum or max.

#2 will always calculate both sum and max but only display one result.

-Rob

http://masterssummit.com

http://qlikviewcookbook.com