Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
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
Kushal_Chawda

Create straight table instead of Pivot table. In straight table you can just double click on column header to sort it.

israrkhan
Specialist II
Specialist II
Author

you did not get me..?

i dont want to sort values, i want to sort the Heading...

currently i have APPLE ! SAMSUNG

But i want  SAMSUNG then Apple,

is it clear?

Kushal_Chawda

Sorry to misunderstood.. Can you please post the sample app?

marcus_sommer

You need to put a sorting on your dimension Brand within the script, maybe by an additionally field which containde the sort-order or you used a dual-field for your dimension Brand, maybe in this way:

BrandSorting:

Load * Inline [

Brand, BrandSorting

Samsung, 1

Apple, 2

...

];

then you didn't use getfieldselection else concat to get the selected values:

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

then concat has as third parameter a numeric sorting.

- Marcus

Anonymous
Not applicable

Hi,

if I understand right you want to order the column in the temporally order that users select the two brand from a listbox Brand (NOT a static order that you have for example in a table of the database).

Can you confirm this?

Best regards.

israrkhan
Specialist II
Specialist II
Author

let me explain again...

i have two conditional expressions, that sum up data for two selected brands, user can select two brand to see the value, if nothing is selected in brand listbox then chart does not show any thing.

when user select Let say "Nokia" then first expression gets enables, and in the chart i can see two dimension and one expression column(Nokia).

when user select second brand, let say "APPLE" then second expression get enabled, and user can see the data for APPLE, and third expression is column(1)- column(2) this is difference between two selected brands..

up to here , every thing is fine..

but now, what i want ...

i selected nokia first, and then i selected apple.

so i want my first column nokia and second column apple,

but qlikview sort it alphabetically, and shows me first column Apple and second column nokia...

i just want to see at column one, which i select first..and then second column, which i select second..

ss.png

in the above image, first i selected SUMSUNG, then i selected APPLE

but Samsung is at column 2, and apple become column 1.

i want Samsung at column 1, and apple at column 2..

i think its clear now...

Many thanks Guys...

israrkhan
Specialist II
Specialist II
Author

Hi Marcus,

thanks for the idea..

1) i have more than 100 Brands, looking for some short way... 🙂

2) you shared the below expression.

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

i think this expression will sum up the data for selected brands in one value, mean one column.

but i want to compare the two selected brands, and want to show the difference?

that why i have two expressions, where i sum up data for two selected brands..

Kushal_Chawda

Hi,

You can do something like this.

Please see the attached

Anonymous
Not applicable

IsrarKhan,

if I ask again is only to help you better.

And I ask again because a user says to you that you kan use a priority field (STATIC order).

Excuse me but only to be clear.

So, I try do to what you need with alternate state.

Try if this can is good for you.

Regards.