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

Sorting dimensions in a chart

I have a chart showing responses from a survey, where the responses are Strongly Agree, Agree, Neither agree nor disagree, Disagree, Strongly Disagree.

At the moment they are ordering alphabetically, but I'd like to order these as shown above. Any ideas on how I can do this?

Thanks in anticipation.

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Load the possible responses in an inline table using the same field name in the order you require before you load your model data. Then at the end of the script drop this table. Now you can sort on load order, because Qlikview remembers the load order of the first time the field is loaded.

//Before loading your model data:

T_Responses:

LOAD * Inline

[

  Response

  Strongly Agree

  Agree

  Neither agree nor disagree

  Disagree

  Strongly Disagree

];

//... load model data here

//After loading the model data:

DROP Table T_Responses;

The field name in the inline (the first entry) must be the same field name that you use for responses in your model.

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

5 Replies
swuehl
MVP
MVP

Best approach would IMHO to assign the dimension values a dual value (please check the dual() function in the Help), then sort by number.

In the chart, you can use a sort expression:

=match(ResponseField, 'Strongly Agree','Agree','Neither agree nor disagree','Disagree','Strongly Disagree')

Not applicable
Author

You can do this

by sorting by Load order (if you loaded them in the good order)

by sorting them by an Expression (=1, 2, 3, 4, 5) depending on the 5 items listed above  (you load a table with your items & this expression)

Fabrice

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Load the possible responses in an inline table using the same field name in the order you require before you load your model data. Then at the end of the script drop this table. Now you can sort on load order, because Qlikview remembers the load order of the first time the field is loaded.

//Before loading your model data:

T_Responses:

LOAD * Inline

[

  Response

  Strongly Agree

  Agree

  Neither agree nor disagree

  Disagree

  Strongly Disagree

];

//... load model data here

//After loading the model data:

DROP Table T_Responses;

The field name in the inline (the first entry) must be the same field name that you use for responses in your model.

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
fabio_vallone
Creator
Creator

Richard,

One solution is to create a flag into Load Script:

If (Response = 'Strongly Agree', 1,

    If (Response = 'Agree', 2, etc)) as Response_Flag,

Then sort by Response_Flag

Or try the Match() function:    Match(Response, 'Strongly Agree', 'Agree', ...) (result is the position, 1, 2, 3, etc).

Not applicable
Author

Thanks everyone for their help.  All sorted & looking good!