Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculate rank based on current month vs previous month

Greetings

Please help to obtain the desired result for calculating ranks.

I would like to rank the products based on the difference of current month and prior month.

(sum({<product= {"=rank(sum(qty), product<=$(vRank)"}, year = 2016  , month = 2 >}  qty)  )

             -

(sum({<product= {"=rank(sum(qty), product<=$(vRank)"}, year = 2016  , month = 1 >}  qty)  )

Thanks!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Your are still using the old  buggy expression, use

(sum({< year = {$(vMaxYear)}, month= {$(vMaxMth)}>} qty)  -
(
sum({< year = {$(vMaxYear)}, month= {$(vLstMth)}>} qty) )

instead.

View solution in original post

10 Replies
swuehl
MVP
MVP

Sorry, I don't understand.

This is not correct syntax:

{"=rank(sum(qty), product<=$(vRank)"}


Maybe you want


{"=rank(sum(qty))<=$(vRank)"}

Not applicable
Author

Thanks for responding.

The rank must based on the difference of qty of Month 2 and 1.

swuehl
MVP
MVP

Maybe create a straight table with dimension product and as expression

=Rank(

(sum({< year = 2016  , month = 2 >}  qty)  )

             -

(sum({< year = 2016  , month = 1 >}  qty)  )

)

Not applicable
Author

Hi

It's working if the default selection is for all.

If I calculate for top N then not working.

swuehl
MVP
MVP

Not sure what you are telling me or what you are trying to do.

Could you upload a small sample QVW and describe based on your sample the requested result?

Not applicable
Author

I would like to achieve the TOP 5 products based on the differences.

Please find attach the sample qvw file.

swuehl
MVP
MVP

Maybe like this

Not applicable
Author

If I will select top 6 then the result is showing incorrect.

Please find below:

Capture.PNG

swuehl
MVP
MVP

Your are still using the old  buggy expression, use

(sum({< year = {$(vMaxYear)}, month= {$(vMaxMth)}>} qty)  -
(
sum({< year = {$(vMaxYear)}, month= {$(vLstMth)}>} qty) )

instead.