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

Sorting value in a String

Hi Team,

 

I have a variable with this values.

'260 <= X < 440','440 <= X < 620','80 <= X < 260','-100 <= X < 80','80 <= X < 260','260 <= X < 440','440 <= X < 620','620 <= X < 800'

I need to sort this values and store in the variable as follows:

'-100 <= X < 80','80 <= X < 260','260 <= X < 440','440 <= X < 620','620 <= X < 800'

 

How to sort the buckets. please help.

 

 

 

Labels (6)
5 Replies
julian_rodriguez
Partner - Specialist
Partner - Specialist

You may use a Inline table to assign a numerical value to each value, and then on the graphics, use the sort by expression and use the field "SortOrder" . Finally, let the associative model do the rest:

// Create a table for the ranges
RangeNumerical:
Mapping LOAD * INLINE [
Range, SortOrder
'-100 <= X <= 80', 1
'80 < X <= 260', 2
'260 <= X <= 440', 3
'440 < X <= 620', 4
'620 <= X <= 800', 5
];

Jeevayswaran
Contributor III
Contributor III
Author

Hi Julian,

I am creating the bucket in the front end expression. it is dynamic and can not be loaded in backend.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

What expression are you using to create the bucket?

-Rob

Jeevayswaran
Contributor III
Contributor III
Author

I am using the Class fucntion:

class(aggr(SW_CONTRIBUTION_PER_TEU,L2),

(fabs(floor(min(total aggr(SW_CONTRIBUTION_PER_TEU,L2)),100))
+
fabs(ceil(max(total aggr(SW_CONTRIBUTION_PER_TEU,L2)),100))
)/5
,
'X',

floor(min(total aggr(SW_CONTRIBUTION_PER_TEU,L2)),100)

)

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You mentioned a "variable" that contains the class buckets. Are you creating this value with Concat() or something else? The class function you posted would create a Dimension. Sorting the Dimension numeric would give the corrected sort display in a chart.  If you are trying to put all the class labels in a single string, can you post that expression?

-Rob