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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
adamdw
Partner - Contributor
Partner - Contributor

How to filter a set analysis variable with another variable

Hi

I have a core variable (vCurrentSales) defined using set analysis and I don't want to have to recalculate it every time simply to add different filters. Is it possible to pass another variable to it such as a date filter?

Here's an example of the core variable:

vCurrentSales = Sum({$<[Category]={"eCommerce"}>}sale_quantity)

 

And I want to be able to pass a filter to it, something like this:

vMonthStart = vMonthStart = monthstart(Date(Floor(localtime('New York')) - 1, 'YYYY-MM-DD'))

 

Here's an example. It runs and doesn't error, but it doesn't actually filter vCurrentSales to the MonthStart. I've tried dimension filters as well and those also don't work. Any suggestions?

vCurrentSalesThisMonth=$(vCurrentSales({$<[Sales Date]={'>=$(=vMonthStart)'}>}))

Labels (4)
2 Replies
Vegar
MVP
MVP

You could try this. 

vCurrentSales = Sum({$<[Category]={"eCommerce"} $1>}sale_quantity)

vMonthStart = monthstart(Date(Floor(localtime('New York')) - 1, 'YYYY-MM-DD'))

vCurrentSalesThisMonth=$(vCurrentSales([Sales Date]={">=$(=vMonthStart)"}))

 

 

BalaBhaskar_Qlik
Master
Master

May be like this :


Sum({<sale_quantity = {"$(=$(vCurrentSales))"}, [Sales Date]={">=$(=vMonthStart)"}>}Field1)

OR

Sum({<sale_quantity = {"=$(=vCurrentSales)"}, [Sales Date]={">=$(=vMonthStart)"}>}Field1)