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: 
Federicofkt
Contributor III
Contributor III

Splitting measure into categories for filtering

Hi, I'd like to split a measure into 3 categories to use them as a filter, like so:

=if([% utilizzo fine mese]>1 or [% utilizzo fine mese] = '>100%','>100%',
if([% utilizzo fine mese]>0.85,'>85%', '<85%'
)
)

this code is working perfectly fine for the background colors of the column "% utilizzo fine mese" (where instead of the strings there are the colours), but for some reasons is not working when used as a filter selection.

The code is giving no errors, but when I try to use it, only the '<85%' appears and it doesn't work. I can click on it but it's not selected as a filter.

 

Thanks!

 

Labels (1)
11 Replies
ali_hijazi
Partner - Master II
Partner - Master II

I assume you need to use the Class function to classify your results into brackets
check the below link for more details:


https://help.qlik.com/en-US/sense/February2024/Subsystems/Hub/Content/Sense_Hub/Scripting/Conditiona....

hope this helps

I can walk on water when it freezes
Pablo007
Creator
Creator

have you tried to do it on the script?

if([% utilizzo fine mese]>1 or [% utilizzo fine mese] = '>100%','>100%',
if([% utilizzo fine mese]>0.85,'>85%', '<85%')) as "YOURNAME",

Federicofkt
Contributor III
Contributor III
Author

The thing is that % utilizzo fine mese is a principal measure created in the analysis, not a column in my table (as per 'age' in the example provided), how can I apply it to my use case?

Federicofkt
Contributor III
Contributor III
Author

with "script" you mean the editor? 

ali_hijazi
Partner - Master II
Partner - Master II

yes you can use an aggregation with the expression you got

for example:
=AGGR( CLASS ( Max(Date),25) , SerialNo )
replace Max(Date) with your expression
replace SerialNo with the appropriate dimension you want

I can walk on water when it freezes
Federicofkt
Contributor III
Contributor III
Author

I'm sorry but I'm not getting it, I need to split the measure into 3 custom categories, so I don't want any dimension.

=AGGR( CLASS ([% utilizzo fine mese], 100) , '>100%' ) ?

Pablo007
Creator
Creator

yes I do

 

Pablo007_0-1709206527538.png

 

F_B
Creator III
Creator III

Hi, it might be useful to understand what you mean by "filter selection", where do you want to write that code line?

Federicofkt
Contributor III
Contributor III
Author

In a filter component in a sheet in the analysis:

 

Federicofkt_0-1709215825907.png

 

and then typing the code here:

Federicofkt_1-1709215875623.png

 

(sorry for the italian language, but I think it's still understandable)