Forum Discussion

mbidelski's avatar
mbidelski
Helper I
6 years ago

Rank filtered values

Hello, Im trying to create a set of charts like this:

 

The year slicer filters data for the left chart. The right chart uses a copy of years column and measure ignoring the year filter from the slicer :

 

 

ValForChart = CALCULATE(SUM(IPBI[Value]);ALL('Period Map'[FY]))

 

 

I'm using the Top N filter to show just the companies that had the highest values in the given year.

 

But what I really want is to show top 5 AND bottom 5 companies by Value in the filtered year - any idea how to achieve this?

ADDITIONAL INFO:

here is the RankX that amitchandak suggested

 

Rank = RANKX(ALL(IPBI);[ValForChart#];;DESC;Dense)

 

 

And here is what happens:

Every value gets a rank, for each year. I want to show 5 companies, that were highest (and lowest )by Value in a given year. Not just top values out every year and every company.

 

I think a solution would look like this:

 

So now you can see the ranks are the way I need them, but I can only do the SOLUTION measure with a static expression:

 

SOLUTION = CALCULATE(SUM(IPBI[Value]);IPBI[FY2]="2017")

 

 

Hope its clear now. I spent an ungodly amount of time trying to figure this out, and it seems it should be doable, but I am very new to DAX and databases in general. Thank you for any suggestions!

 

UPDATE2

 

Why RANKX with ALLSELECTED does not work:

Only ranks the values from the filtered year, everything else is ranked as the last value. Doesn't work will ALL either, screenshot is above.

UPDATE3

Doesn't work with SELECTEDVALUE, Perdio Map[FY] is the name of the column that is filtered by the slicer. Should I reference it differently?

 

9 Replies