Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, I need to sort the x axis on a chart where the variable takes one of these 5 values:
Alpha, Beta, Gamma, Not Applicable, or None. And i tried the following in "Sorting by Expression" field:
if(Variable='Alpha',1,if(Variable='Beta',2,if(Variable='Gamma',3,if(Variable='Not Applicable',4,5))))
but this has not given me the expected result. Any suggestions how to fix this please.
Thanks and regards,
Ra
One more way is as below:
in Sort expression use the following:
Pick(Match(Variable,'Alpha','Beta','Gamma','Not Applicable','None'),1,2,3,4,5)
For better sorting purpose you can just create Inline like-
Load * inline [
Variable, No
Alpha,1
Beta,2
Gamma,3,
Not Applicable,4,
];
Sort your expression by No field.
Use Dual() to get into work..
Thanks Neha, you mean that part has to go under the Data Load Editor ? ... sorry i am very new to Qlik
Ok not an issue
In your Edit Script add this Inline table.
Or provide me some sample data.
Another possible solution is
In sorting tab write expression
match(fieldName,'Aplha','Beta','Gamma','Not Applicable')
Regards,
Thanks again Neha. Unfortunately, i can not put real data in here due to confidentiality.
I have something like this in the Data Load Editor, and I added your code at the bottom, but it did not work.
-----------------------
Table
Load
Variable
SQL select
Variable
From Table
---------------------------
Load * inline [
Variable, No
Alpha,1
Beta,2
Gamma,3,
Not Applicable,4,
];
------------------
Any suggestions please how to fix it? what is the meaning of that No after Variable ? Thanks very much.
Yes this code is ok.
Now go to front end in your chart/table where you want sorting, in that in sorting tab add the field No .
This will sort variable field according to what result you want.
One more way is as below:
in Sort expression use the following:
Pick(Match(Variable,'Alpha','Beta','Gamma','Not Applicable','None'),1,2,3,4,5)
Thanks Neha, but i still got an error when i loaded the data. I guess this make sense more to me as i increase my knowldge of qlik. Any good reference you would suggest please, other that this forum. Thank you.