Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
AnasAbbasi94
Contributor
Contributor

Optimized way to write if(expression=0,Null(), expresssion)

Hi,

I'm trying to find an optimized way to write an expression. The current requirement is 

if(expression=0,Null(), expresssion)

But I believe if the expression is too heavy(in many case), it may be time and resource consuming when several expressions like this will be together in a straight table. I want to reduce the calculation time.

There is an inbuilt function i.e. Alt but it does opposite of what I need. 

Hence, I'm here for help. Thank you.

Qlik Sense Enterprise on Windows QlikView 

1 Solution

Accepted Solutions
Or
MVP
MVP

I believe what you're using is already the best way to go about it, assuming having a null value is required. I would suggest reconsidering whether a null() is required rather than a 0 in the first place, and I'd also suggest investigating your data model and setup if a basic sum with a set creates a performance issue.

View solution in original post

3 Replies
Anil_Babu_Samineni

@AnasAbbasi94 Hello, what is the expresssion conditon looks like?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
AnasAbbasi94
Contributor
Contributor
Author

expression is simple and has few filters in set analysis.
example: I have expressions stored in variable

eTotalSalesCY= sum({<Year={'2023'}, Dept={'IT'}>}Sales)

I think when I write eTotalSalesCY in the expression like 

if(eTotalSalesCY =0,Null(), eTotalSalesCY ), it will evaluate eTotalSalesCY  twice, I may be wrong but I'm trying to find the most optimized way to write this.

Or
MVP
MVP

I believe what you're using is already the best way to go about it, assuming having a null value is required. I would suggest reconsidering whether a null() is required rather than a 0 in the first place, and I'd also suggest investigating your data model and setup if a basic sum with a set creates a performance issue.