Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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

1 Solution

Accepted Solutions
sunny_talwar

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)

View solution in original post

3 Replies
sunny_talwar

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)

Anonymous
Not applicable
Author

Brilliant - many thanks - and super quick too.

It was the first one by the way.

Cheers

Chris

sunny_talwar

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