Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
nagarwal
Partner - Contributor II
Partner - Contributor II

applying filter on the basis of Dynamic Top values variable

Hello,

I have a requirement where I will have one input variable box where I will provide dynamic Top values for Example say 10. Then on Button Click it should read this variable value and check for Top 10 Sum(Sales) Tax id's and then apply the filter on Taxid Filed for those top Taxid's which have Maximum Sales.

I am new to Qlik Sense So can anyone please suggest a solution.

 

1 Solution

Accepted Solutions
Andrei_Cusnir
Specialist
Specialist

Hello,

 

If my understanding is correct then you want to achieve the following use case scenario:

  1. Allow the user to select the number for "Top Values" to display. e.g. 5 or 10 etc.
  2. Then based on that number, make a button that when is clicked will make the filter selection for e.g. top 5 values or top 10 values.

In that case, these are the steps that you can follow:

  1. I have created a table with fake data for presentation and to ensure that everything is working as expected:
  2. SCREENSHOT
  3. Create the following variable, where the default value is 5:
  4. SCREENSHOT
  5. Create a Variable input object
  6. Under "Appearance > General > Title" use "Set the number for Top Values filtering:"
  7. Under "Appearance > Variable" select the following: 
  8. SCREENSHOT
  9. Create a Button object
  10. Under "Appearance > General > Label" use the expression: "='Select Top $(varTopSales) Values'"
  11. Under "Actions and navigation" add a new action:
  12. SCREENSHOT
  13. Then add a new action:
  14. SCREENSHOT 
  15. And for "Value" use the expression: "=Concat(Aggr(if(rank(sum(Sales),4)<=$(varTopSales),Product), Product), ';')"
  16. This means that the button will first clear the Product field and then will apply the new selections.
  17. The new selections uses the function Rank() to rank the products based on the Sum() of field Sales. Then the Aggr() function will return a list of products and the Concat() function will concatenate all the products names with ';' in between them. This will create a new list of values for the field product that the action will apply as filter selections.

This is the results that I have:

 

As you can see selecting the number 3:

SCREENSHOT

It has selected the Item1, Item 20 and Item 11, because the values are 65, 65 and 42 respectively. 

 

Additionally, if you select the number 5:

SCREENSHOT

It has selected the Item1, Item 20, Item 11, Item 13 and Item 8, because the values are 65, 65, 42, 42 and 33 respectively. 

 

I hope that this information was helpful!

Help users find answers! Don't forget to mark a solution that worked for you! 🙂

View solution in original post

1 Reply
Andrei_Cusnir
Specialist
Specialist

Hello,

 

If my understanding is correct then you want to achieve the following use case scenario:

  1. Allow the user to select the number for "Top Values" to display. e.g. 5 or 10 etc.
  2. Then based on that number, make a button that when is clicked will make the filter selection for e.g. top 5 values or top 10 values.

In that case, these are the steps that you can follow:

  1. I have created a table with fake data for presentation and to ensure that everything is working as expected:
  2. SCREENSHOT
  3. Create the following variable, where the default value is 5:
  4. SCREENSHOT
  5. Create a Variable input object
  6. Under "Appearance > General > Title" use "Set the number for Top Values filtering:"
  7. Under "Appearance > Variable" select the following: 
  8. SCREENSHOT
  9. Create a Button object
  10. Under "Appearance > General > Label" use the expression: "='Select Top $(varTopSales) Values'"
  11. Under "Actions and navigation" add a new action:
  12. SCREENSHOT
  13. Then add a new action:
  14. SCREENSHOT 
  15. And for "Value" use the expression: "=Concat(Aggr(if(rank(sum(Sales),4)<=$(varTopSales),Product), Product), ';')"
  16. This means that the button will first clear the Product field and then will apply the new selections.
  17. The new selections uses the function Rank() to rank the products based on the Sum() of field Sales. Then the Aggr() function will return a list of products and the Concat() function will concatenate all the products names with ';' in between them. This will create a new list of values for the field product that the action will apply as filter selections.

This is the results that I have:

 

As you can see selecting the number 3:

SCREENSHOT

It has selected the Item1, Item 20 and Item 11, because the values are 65, 65 and 42 respectively. 

 

Additionally, if you select the number 5:

SCREENSHOT

It has selected the Item1, Item 20, Item 11, Item 13 and Item 8, because the values are 65, 65, 42, 42 and 33 respectively. 

 

I hope that this information was helpful!

Help users find answers! Don't forget to mark a solution that worked for you! 🙂