Forum Discussion
Find the Second Highest Value
Hi Petersfield
I'm wondering if we can take advantage of the RANK function and then look for items where RANK = 2 ???
Do you have some sample data we can try this on?
Hey Phil!
Sure, here's an example below of one product for one territory. What I would be looking to do is display is the Sum of the second highest week since launches sales, and then if possible the percentage change between the second higest and third highest week since launch.
Thanks!
| Date | Platform | Title | Sales Territory | Measure Name | Sales | Weeks Since Launch |
| 20/03/2017 | MS1 | WDD2.1 | United States | WAU | 42016 | 19 |
| 13/03/2017 | MS1 | WDD2.1 | United States | WAU | 118464 | 18 |
| 06/03/2017 | MS1 | WDD2.1 | United States | WAU | 114464 | 17 |
| 27/02/2017 | MS1 | WDD2.1 | United States | WAU | 121696 | 16 |
| 20/02/2017 | MS1 | WDD2.1 | United States | WAU | 136992 | 15 |
| 13/02/2017 | MS1 | WDD2.1 | United States | WAU | 129920 | 14 |
| 06/02/2017 | MS1 | WDD2.1 | United States | WAU | 159072 | 13 |
| 30/01/2017 | MS1 | WDD2.1 | United States | WAU | 175328 | 12 |
| 23/01/2017 | MS1 | WDD2.1 | United States | WAU | 183552 | 11 |
| 16/01/2017 | MS1 | WDD2.1 | United States | WAU | 191936 | 10 |
| 09/01/2017 | MS1 | WDD2.1 | United States | WAU | 208384 | 9 |
| 02/01/2017 | MS1 | WDD2.1 | United States | WAU | 265792 | 8 |
| 26/12/2016 | MS1 | WDD2.1 | United States | WAU | 316896 | 7 |
| 19/12/2016 | MS1 | WDD2.1 | United States | WAU | 192544 | 6 |
| 12/12/2016 | MS1 | WDD2.1 | United States | WAU | 104544 | 5 |
| 05/12/2016 | MS1 | WDD2.1 | United States | WAU | 116736 | 4 |
| 28/11/2016 | MS1 | WDD2.1 | United States | WAU | 135296 | 3 |
| 21/11/2016 | MS1 | WDD2.1 | United States | WAU | 160672 | 2 |
| 14/11/2016 | MS1 | WDD2.1 | United States | WAU | 128320 | 1 |
| 20/03/2017 | P4S | WDD2.1 | United States | WAU | 49024 | 19 |
| 13/03/2017 | P4S | WDD2.1 | United States | WAU | 129856 | 18 |
| 06/03/2017 | P4S | WDD2.1 | United States | WAU | 130400 | 17 |
| 27/02/2017 | P4S | WDD2.1 | United States | WAU | 148800 | 16 |
| 20/02/2017 | P4S | WDD2.1 | United States | WAU | 167488 | 15 |
| 13/02/2017 | P4S | WDD2.1 | United States | WAU | 146496 | 14 |
| 06/02/2017 | P4S | WDD2.1 | United States | WAU | 184480 | 13 |
| 30/01/2017 | P4S | WDD2.1 | United States | WAU | 199168 | 12 |
| 23/01/2017 | P4S | WDD2.1 | United States | WAU | 213344 | 11 |
| 16/01/2017 | P4S | WDD2.1 | United States | WAU | 235136 | 10 |
| 09/01/2017 | P4S | WDD2.1 | United States | WAU | 240128 | 9 |
| 02/01/2017 | P4S | WDD2.1 | United States | WAU | 312512 | 8 |
| 26/12/2016 | P4S | WDD2.1 | United States | WAU | 377952 | 7 |
| 19/12/2016 | P4S | WDD2.1 | United States | WAU | 245920 | 6 |
| 12/12/2016 | P4S | WDD2.1 | United States | WAU | 146400 | 5 |
| 05/12/2016 | P4S | WDD2.1 | United States | WAU | 163552 | 4 |
| 28/11/2016 | P4S | WDD2.1 | United States | WAU | 192160 | 3 |
| 21/11/2016 | P4S | WDD2.1 | United States | WAU | 224256 | 2 |
| 14/11/2016 | P4S | WDD2.1 | United States | WAU | 175520 | 1 |
| 20/03/2017 | iPC | WDD2.1 | United States | WAU | 3712 | 19 |
| 13/03/2017 | iPC | WDD2.1 | United States | WAU | 10112 | 18 |
| 06/03/2017 | iPC | WDD2.1 | United States | WAU | 11776 | 17 |
| 27/02/2017 | iPC | WDD2.1 | United States | WAU | 12768 | 16 |
| 20/02/2017 | iPC | WDD2.1 | United States | WAU | 15904 | 15 |
| 13/02/2017 | iPC | WDD2.1 | United States | WAU | 17504 | 14 |
| 06/02/2017 | iPC | WDD2.1 | United States | WAU | 17952 | 13 |
| 30/01/2017 | iPC | WDD2.1 | United States | WAU | 21248 | 12 |
| 23/01/2017 | iPC | WDD2.1 | United States | WAU | 23296 | 11 |
| 16/01/2017 | iPC | WDD2.1 | United States | WAU | 33344 | 10 |
| 09/01/2017 | iPC | WDD2.1 | United States | WAU | 33824 | 9 |
| 02/01/2017 | iPC | WDD2.1 | United States | WAU | 40448 | 8 |
| 26/12/2016 | iPC | WDD2.1 | United States | WAU | 50848 | 7 |
| 19/12/2016 | iPC | WDD2.1 | United States | WAU | 40608 | 6 |
| 12/12/2016 | iPC | WDD2.1 | United States | WAU | 36768 | 5 |
| 05/12/2016 | iPC | WDD2.1 | United States | WAU | 45024 | 4 |
| 28/11/2016 | iPC | WDD2.1 | United States | WAU | 45152 | 3 |
| 21/11/2016 | iPC | WDD2.1 | United States | WAU | 224 | 2 |
- Phil_Seamark9 years ago
Microsoft Employee
Hi Petersfield
Sorry for the delay in replying
Please try adding the following 2 calculated columns to your table
Week Sales = CALCULATE(SUM('Table1'[Sales]),ALLEXCEPT('Table1',Table1[Date]))and
Ranking On Week Sales = VAR CurrentWeekSales = 'Table1'[Week Sales] RETURN COUNTROWS( FILTER( ALL(Table1[Week Sales]), 'Table1'[Week Sales] < CurrentWeekSales) ) + 1This assigns a ranking value to each week based on the sum of sales.
You can then build the following calculated measure on your table that use the above column (repeat for 3rd highest week) or just use the column above.
Sum of second highest week = CALCULATE( SUM('Table1'[Sales]), FILTER( 'Table1', 'Table1'[Ranking On Week Sales] = 2) )- OscLar8 years ago
Helper I
Hi,
New to PBI and I hope it's ok that I continue this topic.Have a question for Phil_Seamark
I have a very similar situation as the original question though I'm trying to rank days of a year from 1-364 (yes 364, I'm missing the last day of the year).
However I run into trouble when multiple days have the same numerical value I want to rank. For instance I have two days, April 23 and October 15, both with a value of 2034 and they each get assigned rank number 42. And there are a few other such instances. This means that I end up with a table of 360 distinct rank values, where I'd hoped to have 364.
I've tried adding filtering options to your "Ranking on week sales" to get around this problem but I can't seem to figure it out. Let's say I want the date which comes first in the year (April 23) to have rank 42, and October 15 to get rank 43.
Can you pleas help me, or point me in the right direction.
Cheers,
Oscar
- Phil_Seamark8 years ago
Microsoft Employee
- girishsinghal6 years agoNew Member
When I apply the first calculated column and create a table visual I get the below data.
Platform Week Sales iPC 6841888 MS1 7145728 P4S 7145728 Can you please help me understand how I got this?
Regards,
Girish