Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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)
)))))))
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