Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

ts3st1000
New 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
Honored Contributor

Re: Sorting X Axis variable

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)

13 Replies
neha_shirsath
Valued Contributor

Re: Sorting X Axis variable

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.

Re: Sorting X Axis variable

Use Dual() to get into work..

ts3st1000
New Contributor

Re: Sorting X Axis variable

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

neha_shirsath
Valued Contributor

Re: Sorting X Axis variable

Ok not an issue

In your Edit Script add this Inline table.

Or provide me some sample data.

big_dreams
Contributor III

Re: Sorting X Axis variable

Another possible solution is

In sorting tab write expression

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

Regards,

ts3st1000
New Contributor

Re: Sorting X Axis variable

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
Valued Contributor

Re: Sorting X Axis variable

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
Honored Contributor

Re: Sorting X Axis variable

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
New Contributor

Re: Sorting X Axis variable

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.