Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
hadari
Contributor III
Contributor III

KPI rank

Hi,sales

I have ranked my stores by sum(sales) by the expression: rank(sum(sales).

I want to create a KPI that will indicate my rank store based on the name store.
for example:

If my store las Vages is ranked as 13. I want my KPI to show 13 at any time I choose this specific store.
if I just put this expression rank(sum(sales) I will always get 1 because I am filtered in this specific store..

how do I get 13 for example for the choose store? 

Labels (3)
1 Solution

Accepted Solutions
ersanalkan
Partner - Contributor II
Partner - Contributor II

Can you share  vSelectedStore definition in the variable module

Also, Can you put this variable into a text field what you see =$(vSelectedStore)&'-'&"$(vSelectedStore)"

View solution in original post

8 Replies
ersanalkan
Partner - Contributor II
Partner - Contributor II

Hi

This code piece giving us Rank of selected BrickName by Market size in a text field. 

Only({1<BrickName={"$(vSelectedBrickName)"}>} Aggr(Rank(Sum({<BrickName=,IsCurrent={'CY'},Period={'MTD'}>} MarketUnit*MarketOwnerShip)),BrickName))

 

Lets look to the pieces

1.

vSelectedBrickName  is a variable retreives existing selection of brickname. Variable definition is below

vSelectedBrickName =GetFieldSelections(BrickName)

 

2.then the measure

Aggr(Rank(Sum({<BrickName=,IsCurrent={'CY'},Period={'MTD'}>} Unit*Ownership)),BrickName)

2.1  "Sum({<IsCurrent={'CY'},Period={'MTD'}>} Unit*Ownership)" this part of code is standard measure. if you do rank measure by Brick Name  put neutralization code piece BrickName=       into set analysis

2.2 Then put you measure into  Rank then aggr 

Aggr(Rank(Sum()),BrickName) finds the rank

 

2.3 to bring the value to measure

Only({1<BrickName={"$(vSelectedBrickName)"}>} Aggr()) 

 

if you need the same value in tabular objects following is giving the same result

Rank(Total(Sum({<IsCurrent={'CY'},Period={'$(vPeriod)'}>}MarketUnit*MarketOwnerShip)))

 

hadari
Contributor III
Contributor III
Author

Hi! How is it relevant to my example?😊 

I want to rank sales of stores.. and to remain the rank of the selected store if I choose this store by filter

ersanalkan
Partner - Contributor II
Partner - Contributor II

as first step

create a variable

vSelectedStoreName=GetFieldSelections([StoreName])

 

Measure shoul be like this

Only({1<[StoreName]={"$(vSelectedStoreName)"}>} Aggr(Rank(sum( {<[StoreName]= >} Sales)),[StoreName]))

hadari
Contributor III
Contributor III
Author

hadari_0-1713638248070.png

It's says OK but it doesn't recognize the selected storename even though I put it in a KPI and it does recognize the name of the store:

hadari_1-1713638327551.png

I get for this expression '-'

hadari_2-1713638369432.png

 

ersanalkan
Partner - Contributor II
Partner - Contributor II

Hi

StoreName  and Sales should be replaced with your document's field names 

hadari
Contributor III
Contributor III
Author

Hi, I did replace it to my document field- sales is TotalPriceBeforeVat..
but it still not working..

hadari
Contributor III
Contributor III
Author

it does work if I write specific storename:
Only({1<[Store Name]={"Clinton Crossing Premium Outlets"}>} Aggr(Rank(sum({<[Store Name]=>} TotalPriceBeforVat)), [Store Name]))

but with the variable it doesn't recognize it:
Only({1<[Store Name]={"$(vSelectedStore)"}>} Aggr(Rank(sum( {<[StoreName]= >} TotalPriceBeforVat)),[StoreName]))

see the error below:

hadari_3-1713643007609.png

 

ersanalkan
Partner - Contributor II
Partner - Contributor II

Can you share  vSelectedStore definition in the variable module

Also, Can you put this variable into a text field what you see =$(vSelectedStore)&'-'&"$(vSelectedStore)"