Qlik Community

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Customer & Partners, DEC. 9, 11 AM ET: Qlik Product & Strategy Roadmap Session: Data Analytics REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
adamdw
Partner
Partner

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 (5)
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)"}))

 

 

Plees ekskuse my Swenglish and or Norweglish spelling misstakes
balabhaskarqlik

May be like this :


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

OR

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