Skip to main content
Announcements
See why Qlik was named a Leader in the 2024 Gartner® Magic Quadrant™ for Data Integration Tools for the ninth year in a row: Get the report
cancel
Showing results for 
Search instead for 
Did you mean: 
StacyCui
Creator
Creator

IF function expression

Hi, Recently, I wrote a if function.  For example, Compare CY and PY OR , I wrote two same if function expression,  For the screenshot, CY and PY OR are both 0. but the if function results are different. Why has it happened?

expression:

=if(Min_Registration>='2022-10-01' and aggr(sum({<FY={'FY22-FY23'}>}CY_OR),ECODE)>0 ,dual('New with OR',7),
if(Min_Registration>='2022-10-01' and aggr(sum({<FY={'FY22-FY23'}>}CY_OR),ECODE)<=0 ,dual('New w/o OR',6),
if(aggr(sum({<FY={'FY22-FY23'}>}CY_OR),ECODE)>0 and aggr(sum({<FY={'FY22-FY23'}>}PY_OR),ECODE)<=0 ,dual('Woken UP',5),
if(aggr(sum({<FY={'FY22-FY23'}>}CY_OR),ECODE)<=0 and aggr(sum({<FY={'FY22-FY23'}>}PY_OR),ECODE)>0 ,dual('Lost',2),
if(aggr(sum({<FY={'FY22-FY23'}>}CY_OR),ECODE)<=0 and aggr(sum({<FY={'FY22-FY23'}>}PY_OR),ECODE)<=0 ,dual('Sleeping',1),
if(aggr(sum({<FY={'FY22-FY23'}>}CY_OR),ECODE)<=(1-$(ratio))* aggr(sum({<FY={'FY22-FY23'}>}PY_OR),ECODE) ,dual('Signif Drop',3),
if(aggr(sum({<FY={'FY22-FY23'}>}CY_OR),ECODE)>=($(ratio)+1)* aggr(sum({<FY={'FY22-FY23'}>}PY_OR),ECODE) ,'Signif Grow',dual('Normal',4)
)))))))

 

StacyCui_0-1682567137404.png

 

Labels (2)
1 Reply
Chanty4u
MVP
MVP

It's difficult to determine the exact cause of the issue without seeing the data and the full expression, but here are a few possibilities:

 

The if conditions are being evaluated in a different order than you intended, resulting in different outcomes. You could try re-ordering the if statements to see if it resolves the issue.

 

There may be some differences in the data between CY_OR and PY_OR fields that are causing the different outcomes. You could try comparing the values of these fields for the rows where the if statements are returning different results.

 

There may be some issues with the aggregation of the CY_OR and PY_OR fields that are causing unexpected results. You could try breaking down the expression into smaller parts and verifying the intermediate results to identify any issues.

 

It's possible that there are some syntax errors or typos in the expression that are causing the issue. You could try double-checking the syntax and verifying that all the field names are correct