Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
israrkhan
Specialist II
Specialist II

Sort Expression in straight table...

Hello Community,

i have a problem with sorting in straight table.. let me explain me..

i have a pivot table with two dimension and 3 expressions.

my expression are below:

1) SUM({<Brand = {"$(=trim(subfield(GetFieldSelections(Brand),',',1)))"}>} SellOut.Total_Sale)

2) SUM({<Brand = {"$(=trim(subfield(GetFieldSelections(Brand),',',2)))"}>} SellOut.Total_Sale)

3) column(1) -column (2)

user can select 2 Brand to see the difference , between two Brands. (i have more than 50 brands in list box)

let say if i select "SAMSUNG" AND "APPLE" in brand listbox. my chart look like below...(sample)

ss.png

in the image above, store is my dimension, and APPLE is my first expression, and SAMSUNG is second Expression.

its sorted alphabetically....

but i want first column, which i select first, and second column which i select on no two..

let say if i select Samsung first, and then i select apple, then Samsung must be first column, and apple must be second...

but whatever i select it sort alphabetically all the time..

any idea....

Many Thanks

16 Replies
israrkhan
Specialist II
Specialist II
Author

this is what i have currently...

when you select samsung and apple in your brand list, then all the time apple comes as first column..even if you select sumsung first...

i want first column which i select first...

Anonymous
Not applicable

I'm very happy this can help you.

I try also to find a way to save in which order user select the values in a listbox but I dont find nothing, unfortunatelly.

Best regards.

israrkhan
Specialist II
Specialist II
Author

yes, this is what i want...

but without alternate state.... 🙂

i have more than 100 brands, in your suggestions, i have to put two list boxes for same brands,

and user will chose two brands from two list boxes...

thanks for your time...really appreciate your effort..

many thanks

Anonymous
Not applicable

You are wellcome!

I'm very interesting if it is possible to store the users selection order in a Listbox.

Best regards.

Anonymous
Not applicable

surely we can help once u post ur application here...

Anonymous
Not applicable

This can be done by changes in the script. there you have to mention the way u want it..done the same thing in the past...

marcus_sommer

No, it's not sum all all possible brand-values - it takes only the first brand-value and it meant you need further to use two expressions - I have only one expression showed as example, therefore:

SUM({<Brand = {"$(=subfield(concat(distinct Brand, ',', BrandSorting),',',1))"}>} SellOut.Total_Sale)

SUM({<Brand = {"$(=subfield(concat(distinct Brand, ',', BrandSorting),',',2))"}>} SellOut.Total_Sale)

column(1) -column (2)

It's only the same like your example only that it used concat which offered as adavantage against getfieldselection a sorting option and which could be extend with additional condition maybe with an included set analysis.

And I fear it's the easiest and shortest solution. You could of course try to define the order with variables and actions but this is quite complex and it will fail if there is a multiple selection at one time (for example selection by pressing the ctrl-key). Further you could check which Brand has the most or max. value or similar and ordered them to these value.

Another very easy possibilty is to use two fields and listboxes (same values but different fieldnames) with the option to allow only one selected value and use listbox one for expression one and listbox two for expression two.

- Marcus