Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

IF to Set Analysis

How would i convert this IF statement to a set analysis?

(if(Today()-min(Receipt date)<=20, Inventory))

8 Replies
fernandotoledo
Partner - Specialist
Partner - Specialist

Depend on what you are trying to do. If Statements and Set Analisys statements have diferent purposes.

Not applicable
Author

i'm looking to sum up the inventory for items, where the minimum receipt date was less than 20 days ago.

fernandotoledo
Partner - Specialist
Partner - Specialist

Then your IF() is correct and it´s allright use it! You would use set analisys if want to see the result of your calculation for a SET of data different than what is selected.

Not applicable
Author

the only problem i have with the IF statement is that i cannot get subtotals. i can only get grand totals in a straight table, by selecting Sum of Rows. Do i need to modify the IF statement?

johnw
Champion III
Champion III

I thought only a pivot table could give you subtotals. To subtotal in a pivot table:

sum(aggr(your expression,your dimensions))

So perhaps something like this:

sum(aggr(sum(if(today()-min("Receipt Date")<=20,"Inventory")),"Product"))

Not applicable
Author

Hi John,

you are right about subtotals in pivot tables only. i had to settle with a straight table once i realized i couldn't get subtotals. i tried your statement, but get back 0s (no matter what i change the <= value to)

johnw
Champion III
Champion III

If you post an example file, I can make it work. Otherwise, not sure what to tell you.

Not applicable
Author

This seemed to work for me

sum

(aggr(num(if(Today()-min(Receipt DATE_CREATE)<=20, sum(Inventory))),Product))