Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

How to set and use a variable in an expression


In Qlik Sense I was looking to make a dimension which allows filtering by the lowest 20%, middle 60% and the Highest 20%

so my expression was


If(overcrowded_rate <= $(=Max(overcrowded_rate)/100*20), 'Lowest 20%',

If(overcrowded_rate < $(=Max(overcrowded_rate)/100*80), 'Middle 60%',

If(overcrowded_rate >= $(=Max(overcrowded_rate)/100*80), 'Highest 20%',


But when i use this the filtering is allowed but you can filter for the middle 60% of the middle 60%

Can this expression be changed so that it only can be applied once

Thank you

2 Replies

How about this?

If(overcrowded_rate <= Max(TOTAL overcrowded_rate)/100*20, 'Lowest 20%',

If(overcrowded_rate < Max(TOTAL overcrowded_rate)/100*80, 'Middle 60%',

If(overcrowded_rate >= Max(TOTAL overcrowded_rate)/100*80), 'Highest 20%',


Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

May be try this

If(Only({<overcrowded_rate>} overcrowded_rate) <= (Max({<overcrowded_rate>} TOTAL overcrowded_rate)/100*20), 'Lowest 20%',

If(Only({<overcrowded_rate>} overcrowded_rate) < (Max({<overcrowded_rate>} TOTAL overcrowded_rate)/100*80), 'Middle 60%',

If(Only({<overcrowded_rate>} overcrowded_rate) >= (Max({<overcrowded_rate>} TOTAL overcrowded_rate)/100*80), 'Highest 20%',


Or this

If(Only({1} overcrowded_rate) <= (Max({1} TOTAL overcrowded_rate)/100*20), 'Lowest 20%',

If(Only({1} overcrowded_rate) < (Max({1} TOTAL overcrowded_rate)/100*80), 'Middle 60%',

If(Only({1} overcrowded_rate) >= (Max({1} TOTAL overcrowded_rate)/100*80), 'Highest 20%',