Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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
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')
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
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
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).
Thanks everyone for their help. All sorted & looking good!