Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Applicable88
Creator III
Creator III

Why need to aggregate a double IF-statement for variable

Hello,

I'm using a variable in a button to switch a dynamic table.

I have Order Id's which have Status K and others have the Status V:

erStatusStartdate
111111K18.06.2020
222222V19.06.2020
333333V22.06.2020
444444K24.06.2020

The formula for the dimension startdate.autocalendar.date is like following: 

if(If(vVariable='0',count({<Status={"K"}>]Orders),
count({<Status={"V"}>]Orders)))>0,
StartingDate.autocalendar.date))

So practically it means if the button switch is set to variable '0', count orders with K otherwise count orders with V and in either option, the value needs to be greater than 0, then it should return me the dimension startingDate.  I'm wondering why I get no returns.

Only with aggr I get the switch between these working:

aggr(if(If(vVariable='0',count(distinct Orders),
count(distinct Orders2))>0,
StartingDate.autocalendar.date)),StartingDate.autocalendar.date)

Can someone explain to me why I need to aggr and put another StartingDate to the end? For me the first function was fine, its practically the same as the following single if-statement  function simplified, just that it has no variable and no Status K and V filter:

if(Order>0,StartingDate,0)   

Of course this one has no Status K,V filter and no variables. But it returns me every StartingDate for EVERY row, as long there is a OrderId given.

Thanks in advance.

 

0 Replies