Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to set and use a variable in an expression

Hello

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%',

null())))

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
Anil_Babu_Samineni

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%',

null())))

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

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)
sunny_talwar

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%',

Null())))

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%',

Null())))