Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dynamic Button to Select Top n Values

Hi,

I want to have a button that when pressed selects the top n values of a field but I also would really like a user to be able to input how many values and which of the fields (Cost, Revenue, Margin) it selects over.

In the button options I have tried 'Select in Field' but don't know what to put for the Search String. I also don't know how to incorporate inputs into a buttons functionality.

Any help would be much appreciated!

10 Replies
danielrozental
Master II
Master II

Can't you just use a straight table, you can set how many rows are seen by changing "max number" in the presentation tab, you can use a variable to set that.

danielrozental
Master II
Master II

If the above doesn't help you can try something like this

="=rank(aggr(sum(Sales),Customer))<=" & variableN

Not applicable
Author

I could have a separate table where users could select the contents but I'd rather have a shiny button on each page of graphs that selects the best and worst. I tried =rank(aggr(sum(Cost), Customer))<=10 in the search string but it doesn't seem to do anything.

gandalfgray
Specialist II
Specialist II

You could use Input Field to set a variable (vLimit in my example).

Use that variable in the Presentation->Max Number setting of your chart.

maxnum.JPG

lironbaram
Partner - Master III
Partner - Master III

hei

attach is an example

maybe it can help you

what the user will have to do is select the measure for filter

number of top Customers

and the table will filter

Not applicable
Author

I only have personal edition so can't open other people's files. Is it possible for you to explain what you've done with some code?

Thanks!

lironbaram
Partner - Master III
Partner - Master III

ok let try
attach is an excel file which is my sorce data
my script looks like this:
Data:
LOAD CustomerID,
CustomerName,
Sales,
Cost,
Profit
FROM

(
ooxml, embedded labels, table is גיליון1);

LOAD * INLINE [
Meas
sum(Sales)
sum(Cost)
sum(Profit)
]
;
then i have this objects in the appliction:
list box of the filed Meas
input box for a Varaible with the name vNum
Chart of Stright Table with
dimension: =aggr(if(rank($(=only(Meas)) )<=vNum,CustomerName),CustomerName)
with the box: Supress when null is values - Checked
expressions:
sum(sales)
sum(profit)
sum(cost)
try to bulid a qvw file like that and then follow what i wrote in the previous post
SunilChauhan
Champion II
Champion II

hello ,

Take i inline like below

Load * Inline [

ColName

Top1

Top2

Top3

:

:

:

:

Top N

];

in chart u want n max

go to presentation and in max number shown  option write code below

If(ColName='Top1',1,if(ColName='Top2',2,...........))

hope it will work for you

thanks

Sunil Chauhan

Sunil Chauhan
Not applicable
Author

You can use a Slider control to let the user select a value into a variable.  Then in the Presentation tab, in the Max visible number, reference the variable used in the Slider control.