Qlik Community

Qlik Sense App Development

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

chrisweldon
New Contributor III

Setting Selection Criteria as a Variable

Hi,

I have an app that has about 60 visualisations across 10 sheets.  In each visualisation I am using the same criteria in set analysis to filter the results.  This makes it a bit hard for people who are trying to understand what I have done, and also painful if I want to change the standard criteria.  So I would like to set the standard criteria that appear on every visualisation up as a variable at a Quote level (the standard unit of counting for this app).  Then in each visualisation I want to check if the variable is Yes or No for that Quote and will include / exclude on that basis.

So for example the standard set analysis criteria are:

count(distinct{<Q_QUOTE_TrackedQuote={'Yes'},Q_QUOTE_QuoteType-={'Research'},Q_QUOTE_QuoteStatus*={'Issued','Finalised'},

Q_QUOTE_StartDate={">=$(=date(vStartDate,'DD/MM/YYYY'))<=$(=date(vEndDate,'DD/MM/YYYY'))"}>}CaseID)

In this case I happen to be counting the CaseID, but I might be summing premium or something else, but it always uses the same criteria in the set analysis.  This all works fine.

I have tried adding that Set Analysis to a variable like this using AGGR to get an answer at QuoteID level:

aggr(if(count(distinct{<Q_QUOTE_TrackedQuote={'Yes'},Q_QUOTE_QuoteType-={'Research'},Q_QUOTE_QuoteStatus*={'Issued','Finalised'},

Q_QUOTE_StartDate={">=$(=date(vStartDate,'DD/MM/YYYY'))<=$(=date(vEndDate,'DD/MM/YYYY'))"}>}CaseID)>0,'Yes','No'),QuoteID)

Then I tried to use the variable in a table as follows:

count(distinct{<'$(=$(vQuoteIncludedInSelection))='Yes''>}CaseID)

I have also tried various other syntaxes but still get a series of Nulls as an answer.

Am I missing something obvious?

Many thanks to you all in advance.

Chris

Tags (1)
1 Solution

Accepted Solutions

Re: Setting Selection Criteria as a Variable

What if you add this to a variable

vVar

{<Q_QUOTE_TrackedQuote={'Yes'},Q_QUOTE_QuoteType-={'Research'},Q_QUOTE_QuoteStatus*={'Issued','Finalised'}, Q_QUOTE_StartDate={">=$(=date(vStartDate,'DD/MM/YYYY'))<=$(=date(vEndDate,'DD/MM/YYYY'))"}>}

and then use this like this

Count(Distinct $(vVar) CaseID)

or you might need an equal sign

Count(Distinct $(=vVar) CaseID)

3 Replies

Re: Setting Selection Criteria as a Variable

What if you add this to a variable

vVar

{<Q_QUOTE_TrackedQuote={'Yes'},Q_QUOTE_QuoteType-={'Research'},Q_QUOTE_QuoteStatus*={'Issued','Finalised'}, Q_QUOTE_StartDate={">=$(=date(vStartDate,'DD/MM/YYYY'))<=$(=date(vEndDate,'DD/MM/YYYY'))"}>}

and then use this like this

Count(Distinct $(vVar) CaseID)

or you might need an equal sign

Count(Distinct $(=vVar) CaseID)

chrisweldon
New Contributor III

Re: Setting Selection Criteria as a Variable

Brilliant - many thanks - and super quick too.

It was the first one by the way.

Cheers

Chris

Re: Setting Selection Criteria as a Variable

Variables often confuses me... its a hit and trial when it comes to variable for me...

Community Browser