Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

wonkymeister
Contributor

Rank in Textbox as KPI

Afternoon all!

i need to use the Rank function in a textbox as a KPI

i.e. without the dimension - just as an expression. i only want to display the rank of a single product.

For example i have 20 products with sales volume. i want to display in a text box the rank that one particular product is at. I've got this working fine in a chart with a dimension - but i have no idea how to script this as a single expression.

so as a chart this works perfectly:

Dimension: Products

Expression: =rank(sum(Sales_Volume))

but how do i go about writing the expression to take into account the dimension?

cheers!

1 Solution

Accepted Solutions
jvitantonio
Valued Contributor III

Re: Rank in Textbox as KPI

In your case, you'll need to select the product you want to display. if you always need to see the rank for a particular product, then you need to place the product in the expression using set analysis.

Ex:

aggr(rank(TOTAL sum({1 <Product = {'B'}>} Sales)), Product)

Please find the solution in the attached file.

JV

7 Replies
neetha_p
Honored Contributor

Re: Rank in Textbox as KPI

Hi,

Try:

=aggr(if(rank(sum(Sales))=1,Product),Product)


Regards

Neetha

wonkymeister
Contributor

Re: Rank in Textbox as KPI

thanks but that displays the number 1 product.

i want to display the rank for a particular product which i'll hardcode into the expression.

jvitantonio
Valued Contributor III

Re: Rank in Textbox as KPI

In your case, you'll need to select the product you want to display. if you always need to see the rank for a particular product, then you need to place the product in the expression using set analysis.

Ex:

aggr(rank(TOTAL sum({1 <Product = {'B'}>} Sales)), Product)

Please find the solution in the attached file.

JV

wonkymeister
Contributor

Re: Rank in Textbox as KPI

thanks QL - works great. any tips on how i would hard code a particular product into the set analysis?

thornofcrowns
Valued Contributor II

Re: Rank in Textbox as KPI

QL has shown you how to do this. Replace <Product={'B'}> with your product information.

Not applicable

Re: Rank in Textbox as KPI

thanks for this very useful post

wonkymeister
Contributor

Re: Rank in Textbox as KPI

thanks James-  missed that.

never do anything tricky on a Friday

Community Browser