Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Chart/Graph Dimension Sort/Order on x Axis

HI All (my first post on QView community forum)

I am having problems with the sorting of the dimensions on the x axis of a chart.

This is the code for a dimension i have which groups a field i have.

  Code.bmp

The graph appears like this. With the ages completely out of order.

Graph.bmp

5 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Check attached file for solution.

Hope it helps you.

Regards,

Jagan.

Not applicable
Author

Apologies   

i have ages 16 - 95. Would i need to create a Load inline for every age?

I also have around 50 other data items. would i need to create a preceeding load to bring in these additional items ??

Thanks for your help

James

Not applicable
Author

HI

This was suggested to me. But it didnt work. Any Ideas ?

=wildmatch(if(Driver_1_Age<=18,'<18',

if(Driver_1_Age<23,'19-23',

if(Driver_1_Age<28,'24-28',

if(Driver_1_Age<33,'29-33',

if(Driver_1_Age<39,'34-39',

if(Driver_1_Age<45,'40-45',

if(Driver_1_Age<50,'46-50',

if(Driver_1_Age<55,'51-55',

if(Driver_1_Age<60,'56-60',

if(Driver_1_Age<65,'61-65',

if(Driver_1_Age<70,'66-70',

if(Driver_1_Age<=74,'71-74',
'75+')))))))))))),'<18','19-23','24-28','29-33','34-39','40-45','46-50','51-55','56-60','61-65','66-70','71-74','75+')

mikecrengland
Creator III
Creator III

You could use a 'dual' function in your calcualted dimension

=If (Driver_1_Age<=18, dual('<18',1),

If (Driver_1_Age<23, dual('<23',2),

etc...

Then sort numerically.

malhaar
Partner - Contributor II
Partner - Contributor II

Another option is to create a table with your ranges:

AgingTable:
LOAD * INLINE [
Seq, From, To, Display
1, 0, 18, < 18
2, 19, 23, 24-28
3, 29, 33, 29-33
...
...
];

Use the IntervalMatch match function to match the age to this table and in the display, use an expression sort on the field 'Seq'

The advantage with this method would be that you can source this info from a 'config' file and do the assignment in the load script itself.