Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How To Filter By Variable

Hello,

I am trying to filter dimension Year by a variable vMinYear. 

I am getting syntax error.

={<Year={$(vMinYear)}>}

Can someone give me a pointer on what I should construct this dimension filter?

Appreciated!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Have you used above line as calculated dimensions?

Anyway, you can't use a set expression stand alone, but you could use it in an aggregation function.

So either use this is calculated dimension:

= if( Year = $(vMinYear), Year)

or use a set expression like above as part of an aggregation function.

if you do a count(Sales) for example, use Year as dimension and

= count( {<Year= {$(vMinYear)}>} Sales)

as expression.

You need to do this limitation then on each expression to get a equal behaviour than using a calculated dimension.

Hope this helps,

Stefan

View solution in original post

3 Replies
swuehl
MVP
MVP

Have you used above line as calculated dimensions?

Anyway, you can't use a set expression stand alone, but you could use it in an aggregation function.

So either use this is calculated dimension:

= if( Year = $(vMinYear), Year)

or use a set expression like above as part of an aggregation function.

if you do a count(Sales) for example, use Year as dimension and

= count( {<Year= {$(vMinYear)}>} Sales)

as expression.

You need to do this limitation then on each expression to get a equal behaviour than using a calculated dimension.

Hope this helps,

Stefan

Not applicable
Author

Thanks Stefan.

Would this syntax work with range?

= if( Year >= $(vMinYear) and Year <= $(vMaxYear), Year)

Much appreciated.

swuehl
MVP
MVP

Yeah, should do.

And

= count( {<Year= {">=$(vMinYear)<=$(vMaxYear)"}>} Sales)

for the set expression should also do.

Filtering with set analysis will probably perform better, but just try both and play a little bit around.