Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Sum(if(...)) vs If(Sum(...), Sum(...))

Hey everyone,

Is there an advantage or difference between using sum(if)) vs if(sum())?

1 Solution

Accepted Solutions
swuehl
MVP
MVP

There is a big difference:

=sum(if( Condition, Then, Else))

Here the condition is evaluated on record level, the result of each evaluation is then aggregated.

=If( sum(), Then, Else)

Here the aggregation happens first, then the result of the aggregation is used in the condition to decide on Then or Else branch.

View solution in original post

2 Replies
marcus_sommer

Yes there are differences. If I rembemer correctly has hic‌ this in one of his blog-postings explained. But better is you forget about it and used instead set analysis, like : sum{< Dimension = {'Some Values'}>} Value)

- Marcus

swuehl
MVP
MVP

There is a big difference:

=sum(if( Condition, Then, Else))

Here the condition is evaluated on record level, the result of each evaluation is then aggregated.

=If( sum(), Then, Else)

Here the aggregation happens first, then the result of the aggregation is used in the condition to decide on Then or Else branch.