Announcements
Join us on Sept. 17 to hear how our new GenAI Assistant empowers data professionals: REGISTER
cancel
Showing results for
Did you mean:
Creator

Qlik sense - Sort by expression (number) and convert number to string (text)

Hi Foks

I have been trying to understand the way to sort by expression and converting numbers in my table to string (text).

And this question may already have been answered numerous times in this forum, but apparently not in a way that I am able to understand it, and use the examples in my table.

The problem is the last Column (Fejlkode)

I would like if the data = errorState

Could be sorted so that the number '2' is always the first, and '4' is the second.

Also, i would like if the number '2' is converted to text 'Critical, must be replaced'  and '4' converted to text 'Cold restart for 21 days'

Hope you are able to help me figure out how to approach this problem.

1 Solution

Accepted Solutions
MVP

=if(Fejlkode=2,'Critical, must be replaced' ,

if(Fejlkode=4,'Cold restart for 21 days' ,

if(Fejlkode=0,'other')))

6 Replies
Master III

to convert try this

if(Fejlkode=2, 'Critical, must be replaced','Cold restart for 21 days') as fieldname

and sort this by Fejlkode
MVP

Create a new dimension as follow:

=if(Fejlkode=2,'Critical, must be replaced' ,'Cold restart for 21 days' )

and for the sorting, you have to put this dimension as the first one and sort it by expression (ascending) : Feljkode

Creator
Author

This one almost worked

if(Fejlkode=2, 'Critical, must be replaced','Cold restart for 21 days')

Only thing is that '0' now is Cold restart for 21 days

How do I define them individually

1=Name1

2=Critical

3=Name3

ect...

MVP

=if(Fejlkode=2,'Critical, must be replaced' ,

if(Fejlkode=4,'Cold restart for 21 days' ,

if(Fejlkode=0,'other')))

Creator
Author

That did the trick

Also The dimension solution worked .....

Thx.

Anonymous
Not applicable

Not working for me. My initial fields were coded as follows:

If(score <=590, 'LT 590',

IF(score >= 590 and score < 620, '590 - 620',

IF(credit >= 620 and score < 640, '620 - 640',

IF(score >= 640 and score < 680, '640 - 680',

IF(score >= 680 and core < 699, '680 - 699',

'700+')))))

In my expression I did the following:

If(score=1,'LT 590',IF(score=2,'590 - 620',

IF(score=3,'620 - 640',IF(score=4, '640 - 680',

IF(score=5,'680 - 699',IF(score=6,'700+'))))))

I also tried the reverse order in the expression as well with no success.  I would appreciate any insight.  Thanks