
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When is it best to use sum(if()) over Set Analysis in an expression?
When is it best to use sum(if()) (or count() etc...) over Set Analysis in an object expression? Is there an advantage of one over the other as it relates to process speed?
Accepted Solutions

.png)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Often the Set analysis is faster than the Sum(If(...)). However, to make a fair comparison you must compare five different cases:
- Sum(if(IsThisYear='True' , Sales))
The string comparison "IsThisYear='True'" is CPU-expensive. Avoid this construction! - Sum(if(Year=2013 , Sales))
A numeric comparison is a lot faster than a string comparison. But still slower than a booloean. - Sum(IsThisYear * Sales)
A multiplication works fine if the aggregation is a Sum. It does not work with Avg or Count. And multiplication is not very fast. - Sum(if(IsThisYear , Sales))
Using the "IsThisYear" as a boolean is faster than using it in a relational comparison. - Sum({$<IsThisYear={1}>} Sales)
Set analysis is often the fastest way.
My view is that alternative 4 or 5 are acceptably fast, but the three first constructions should be avoided.
HIC

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Kindly go though the attached file for clarification on each of the expression.
Regards,
Kaushik Solanki

.png)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Often the Set analysis is faster than the Sum(If(...)). However, to make a fair comparison you must compare five different cases:
- Sum(if(IsThisYear='True' , Sales))
The string comparison "IsThisYear='True'" is CPU-expensive. Avoid this construction! - Sum(if(Year=2013 , Sales))
A numeric comparison is a lot faster than a string comparison. But still slower than a booloean. - Sum(IsThisYear * Sales)
A multiplication works fine if the aggregation is a Sum. It does not work with Avg or Count. And multiplication is not very fast. - Sum(if(IsThisYear , Sales))
Using the "IsThisYear" as a boolean is faster than using it in a relational comparison. - Sum({$<IsThisYear={1}>} Sales)
Set analysis is often the fastest way.
My view is that alternative 4 or 5 are acceptably fast, but the three first constructions should be avoided.
HIC

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes set analysis is the fastest way.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks
This was really very helpful for me!
Regards,
Kuldeep
