Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
youss123
Contributor III
Contributor III

Sort order with Class Function

Hi all,

I want to sort the four graphs :

problem 1 :  the x axis 

youss123_0-1697791684819.png

problem 2 :  the legend , i want to go from insufficent to high and the color red will be for insufficent , yellow for intermediate and green for high

youss123_1-1697791747453.png

 

 

dimension 1  : = replace(class([SCORE  1],10),'<= x <','->')

dimension 2 : 

= If([SCORE  1] >= -100 AND [SCORE  1] < -90, 'insufficient',
    If([SCORE  1] >= -90 AND [SCORE  1] < -80, 'insufficient',
    If([SCORE  1] >= -80 AND [SCORE  1] < -70, 'insufficient',
    If([SCORE  1] >= -70 AND [SCORE  1] < -60, 'insufficient',
        If([SCORE  1] >= -60 AND [SCORE  1] < -50, 'insufficient',
If([SCORE  1] >= -50 AND [SCORE  1] < -40, 'insufficient',
    If([SCORE  1] >= -40 AND [SCORE  1] < -30, 'insufficient',
    If([SCORE  1] >= -30 AND [SCORE  1] < -20, 'insufficient',
    If([SCORE  1] >= -20 AND [SCORE  1] < -10, 'insufficient',
        If([SCORE  1] >= -20 AND [SCORE  1] < -10, 'insufficient',
            If([SCORE  1] >= -10 AND [SCORE  1] < 0, 'insufficient',
            If([SCORE  1] >= 0 AND [SCORE  1] < 10, 'insufficient',
                If([SCORE  1] >= 10 AND [SCORE  1] < 20, 'intermediate',
                    If([SCORE  1] >= 20 AND [SCORE  1] < 30, 'intermediate',
                        If([SCORE  1] >= 30 AND [SCORE  1] < 40, 'high',
                            If([SCORE  1] >= 40 AND [SCORE  1] < 50, 'high',
                                If([SCORE  1] >= 50 AND [SCORE  1] < 60, 'high',
                                    If([SCORE  1] >= 60 AND [SCORE  1] < 70, 'high',
                                        If([SCORE  1] >= 70 AND [SCORE  1] < 80, 'high',
                                            If([SCORE  1] >= 80 AND [SCORE  1] < 90, 'high',

 

Expression : = count(DISTINCT Users)

sort.PNG

 

Thank you in advance ++

Labels (7)
1 Solution

Accepted Solutions
marcus_sommer

Ok. then you may resolve it in this way (simplified): dual(replace(class()), class())

View solution in original post

3 Replies
marcus_sommer

Class() returned a dual() and could be therefore directly numeric sorted. But your replace() makes a string from it. If you don't like the default '<= x <' you could specify your wanted delimiter as the third parameter of class().

Also the nested if-loops could be simplified just by querying if the score is smaller as 10 and greater as 30.

youss123
Contributor III
Contributor III
Author

Hi @marcus_sommer  thank you for your response.

from what I understood, the third parameter of class() replaces the value of x in a<=x<b not the form of the segment.

regards

marcus_sommer

Ok. then you may resolve it in this way (simplified): dual(replace(class()), class())