Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
ts3st1000
Contributor
Contributor

Sorting X Axis variable

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

1 Solution

Accepted Solutions
trdandamudi
Master II
Master II

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)

View solution in original post

13 Replies
neha_shirsath
Specialist
Specialist

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.

Anil_Babu_Samineni

Use Dual() to get into work..

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
ts3st1000
Contributor
Contributor
Author

Thanks Neha, you mean that part has to go under the Data Load Editor ? ... sorry i am very new to Qlik

neha_shirsath
Specialist
Specialist

Ok not an issue

In your Edit Script add this Inline table.

Or provide me some sample data.

big_dreams
Creator III
Creator III

Another possible solution is

In sorting tab write expression

match(fieldName,'Aplha','Beta','Gamma','Not Applicable')

Regards,

ts3st1000
Contributor
Contributor
Author

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.

neha_shirsath
Specialist
Specialist

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.

trdandamudi
Master II
Master II

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)

ts3st1000
Contributor
Contributor
Author

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.