Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
rajeshvaswani77
Specialist III
Specialist III

Optimize if condition

Hi All,

We have a expression that reads

num(if(sum(XYZ)<0, 0, Sum(XYZ)),'$(UnitFormat)')

This seems to be consuming a high calculation time on a large document.

Is there a single function that can be used to optimize this to the best?

Note: for certain reasons we do not want to mention the dimension when we are calculating this.

thanks,

Rajesh Vaswani

5 Replies
ashfaq_haseeb
Champion III
Champion III

Hi,

Can you try below

if(sum(XYZ)<0, 0, num(Sum(XYZ),'$(UnitFormat)'))


Regards

ASHFAQ

Not applicable

You could try:

num(rangemax(0,Sum(XYZ)),'$(UnitFormat)')

Not sure if this will improve performance, but it may be worth a try.

marcus_sommer

Maybe you could use set analysis:

sum({< XYZ = {">0"}>} XYZ)

The units could you better show (dynamically) within the label.

- Marcus

Not applicable

Wouldn't you want to include negative values? Just because one of the values of XYZ is negative, doesn't mean the sum is below 0.

marcus_sommer

It will be depend from the data-structure. In some cases I use such logic. Maybe its worth to implement the sum-check within the set analysis but I think then will be the performance not really better ...

Perhaps another way could be to split these calculation in a table-chart with and reference i a second step on the other column.

- Marcus