Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Luca1
Contributor III
Contributor III

Sort a table using expressions

I want to use a Button to change the sorting of a table (no pivot-table). 

Let's assume that I have 2 columns in the table: Col1 and Col2. If the Button is clicked, I want to change the value of a local variable 'vTableSort' from 'Col1' to 'Col2' and vice-versa. If 'vTableSort' has the value 'Col1', the table should be sorted ascending based on 'Col1'. If 'vTableSort' has the value 'Col2', the table should be sorted descending based on 'Col2'. 

I would appreciate if anyone could help me out with this!

Labels (3)
1 Solution

Accepted Solutions
vikasmahajan

You'll need to drag up this column so it's the first in the sort tab, uncheck sort auto and check 'sort by expression' can use this expression:

If( variable='col1', 'col2', 'col1') 

not sure for button but in pivot report you can do the same.

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.

View solution in original post

5 Replies
anat
Master
Master

Can u try like 

If( variable='col1', 'col2', 'col1') 

Luca1
Contributor III
Contributor III
Author

Where am I supposed to write that? There is no "Sort by Expression" field for a table. 

vikasmahajan

In expression of Sort tab, use below

 

If( variable='col1', 'col2', 'col1') 

another approach :

https://community.qlik.com/t5/New-to-Qlik-Sense/Custom-Sort/td-p/1666109

another approach :

https://community.qlik.com/t5/New-to-Qlik-Sense/Custom-sorting-of-Dimentions/td-p/1285062

https://community.qlik.com/t5/App-Development/Sort-by-expression-filter-box/m-p/1866419#M71527

hope this will help

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
Luca1
Contributor III
Contributor III
Author

Hey, thank you for your reply! I think that this is exactly what I want. However, I can't find an expression field in the sorting tab. Attached you find a screenshot of how it looks like for me. Maybe I misunderstood, where I have to make these changes.

Screen Shot 2021-12-30 at 12.45.17.png

vikasmahajan

You'll need to drag up this column so it's the first in the sort tab, uncheck sort auto and check 'sort by expression' can use this expression:

If( variable='col1', 'col2', 'col1') 

not sure for button but in pivot report you can do the same.

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.