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: 
dafnis14
Specialist
Specialist

Set analysis help

Hi,

I would appreciate some help with set analysis for the following case:

2 data tables:

  • - Inventory data with the fields SupCode, Inventory
  • - Sales Data with the fields Sales_Date, Sales

A straight table with the dimensions:

  • - Supplier Code
  • - Supply Date

For each supply date, the table should show total inventory  for the Supply Date,  and total sales for a period of 30 days previous to that Supply date.

To calculate the sales, I wrote the following expression:

aggr(sum({$<Sales_Date= {">$(= date(Supply_Date -30)) <=$(=date(Supply_Date))"}>} Sales), SupCode)

But it works only if a certain supply date is selected. Otherwise, null values are displayed.

Can someone assist me?

Thanks!


2 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

A set in set analysis is calculated only once, at the start of chart recalculation and not row-by-row.

You can use an AsOf table to solve this problem. See this document Calculating rolling n-period totals, averages or other aggregations for an explanation of why set analysis doesn't work and how AsOf tables can solve most of these rolling period-related problems.

Best,

Peter

dafnis14
Specialist
Specialist
Author

Great!

Thanks!