Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Solved! Go to Solution.
Hi @Vivek26
Please check this measure. Although it is not concise enough, it seems to meet your requirements.
rank =
var currentDistrict = SELECTEDVALUE(Store[District])
var sumTable = SUMMARIZE(ALLSELECTED(Store),Store[Region],Store[District],"Total_Amount",[Total Sales])
var rankTable = ADDCOLUMNS(sumTable,"Rank_Value",RANK(DENSE,sumTable,ORDERBY([Total_Amount],DESC)))
return
MAXX(FILTER(rankTable,[District] = currentDistrict),[Rank_Value])
I struggled a lot but haven't figured out a method with RANKX yet. Hope this would be helpful.
Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!
@Anonymous . Thanks a lot for the reply. The solution worked.
Please do let me know if you are able to solve it with Rankx as well.
I also Invested a lot of time with Rankx but I was not able to find a good solution.
If you filter a specific store in a district, we will again start getting rank 1 for everything . That is my main point of concern.
In a district we want to exclude certain stores .
Hi @Vivek26
Please check this measure. Although it is not concise enough, it seems to meet your requirements.
rank =
var currentDistrict = SELECTEDVALUE(Store[District])
var sumTable = SUMMARIZE(ALLSELECTED(Store),Store[Region],Store[District],"Total_Amount",[Total Sales])
var rankTable = ADDCOLUMNS(sumTable,"Rank_Value",RANK(DENSE,sumTable,ORDERBY([Total_Amount],DESC)))
return
MAXX(FILTER(rankTable,[District] = currentDistrict),[Rank_Value])
I struggled a lot but haven't figured out a method with RANKX yet. Hope this would be helpful.
Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!
Hi @Vivek26 ,
can you let me know in which scenario in my pbix file is giving all ones?
@powerbiexpert22 . Thanks for replying.
I used your pbix but instead of having 3 different slicers . I used a single one and I started getting the same issue.
My Apoligies I should have clarified my usage of slicer
Hi @Vivek26 ,
try to use below
Hi @Vivek26,
please see below pbix for your reference , the rankx function is showing correct results
you will have to create measure first for sales amount and then use it inside rank function ( do not use sum(col) directly in your rank measure
https://drive.google.com/file/d/1TmjidSpb2KktCGYUkfRDQlnc_nAWsL3L/view?usp=drive_link
Hi Greg , Thanks for replying.
The dax doesn't break but the ranking order gets messed up
For example post filtering , Kanpur may get the 3rd Rank while it should be 2nd
@Vivek26 What do you mean by "DAX breaks"? You get an error, you get incorrect results, ... ? You might try RANK instead of RANKX
User | Count |
---|---|
16 | |
15 | |
14 | |
12 | |
11 |
User | Count |
---|---|
19 | |
15 | |
14 | |
11 | |
10 |