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.
Hello Community ,
I am new to PowerBI/Dax world. We have a report which displays Sales reps performance details.
It has a dropdown with Sales reps name and once selected it displays the details of corresponding Sales rep.
Something like below, simplified version just to explain.
Sales Rep Name : AAAA
Metric Amt Rank
Revenue 1000 Calculate Rank based on Revenue amt (desc) across all reps: Expected value from the table below : 2
Margin 10 Calculate Rank based on Margin amt (desc) across all reps: Expected value from the table below : 3
Debt 2000 Calculate Rank based on Budget amt (ascending) across all reps: Expected value from the table below : 2
So we have to calculate the rank of the SaleRep for each Metric across all the reps based on the Amount.
The table structure is
I am trying to calculate the rank using the DAX formula like Rankx but not getting the value expected.
Can someone please help me here.
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
I created for both calculated column and calculated measure.
Ranking CC =
VAR currentmetrics = Data[Metric]
VAR newtable =
FILTER ( Data, Data[Metric] = currentmetrics )
VAR rankingcurrentmetric =
RANKX ( newtable, Data[Amount],, DESC )
VAR rankingdebtmetric =
RANKX ( newtable, Data[Amount],, ASC )
RETURN
SWITCH (
TRUE (),
Data[Metric] IN { "Revenue", "Margin" }, rankingcurrentmetric,
rankingdebtmetric
)
Amount measure: =
IF ( ISFILTERED ( Metrics[Metric] ), SUM ( Data[Amount] ) )
Ranking measure: =
VAR currentmetrics =
MAX ( Metrics[Metric] )
VAR newtable =
FILTER ( ALL ( Data ), Data[Metric] = currentmetrics )
VAR rankingcurrentmetric =
RANKX ( newtable, Data[Amount measure:],, DESC )
VAR rankingdebtmetric =
RANKX ( newtable, Data[Amount measure:],, ASC )
RETURN
IF (
ISFILTERED ( Metrics[Metric] ),
SWITCH (
TRUE (),
SELECTEDVALUE ( Metrics[Metric] ) IN { "Revenue", "Margin" }, rankingcurrentmetric,
rankingdebtmetric
)
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Schedule a short Teams meeting to discuss your question
Hi,
Please check the below picture and the attached pbix file.
I created for both calculated column and calculated measure.
Ranking CC =
VAR currentmetrics = Data[Metric]
VAR newtable =
FILTER ( Data, Data[Metric] = currentmetrics )
VAR rankingcurrentmetric =
RANKX ( newtable, Data[Amount],, DESC )
VAR rankingdebtmetric =
RANKX ( newtable, Data[Amount],, ASC )
RETURN
SWITCH (
TRUE (),
Data[Metric] IN { "Revenue", "Margin" }, rankingcurrentmetric,
rankingdebtmetric
)
Amount measure: =
IF ( ISFILTERED ( Metrics[Metric] ), SUM ( Data[Amount] ) )
Ranking measure: =
VAR currentmetrics =
MAX ( Metrics[Metric] )
VAR newtable =
FILTER ( ALL ( Data ), Data[Metric] = currentmetrics )
VAR rankingcurrentmetric =
RANKX ( newtable, Data[Amount measure:],, DESC )
VAR rankingdebtmetric =
RANKX ( newtable, Data[Amount measure:],, ASC )
RETURN
IF (
ISFILTERED ( Metrics[Metric] ),
SWITCH (
TRUE (),
SELECTEDVALUE ( Metrics[Metric] ) IN { "Revenue", "Margin" }, rankingcurrentmetric,
rankingdebtmetric
)
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Schedule a short Teams meeting to discuss your question
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
19 | |
14 | |
13 | |
11 | |
8 |