Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Sar_Jo19
Regular Visitor

RANKX breaks when other measures are added to table

Hi all,

 

I'm having issues with what should be a simple ranking measure that I've used in exactly the same format in multiple dashboards before now. I have a "Sales Data" table which has columns for Location, Sales, Transactions, Margin. I've created measures for each value as follows: CALCULATE(SUM('Sales Data'[Sales])), I've then created a measure for ATV which is just: DIVIDE([Sales],[Transactions]).

 

I want to rank ATV for each location and am using this measure: CALCULATE(RANKX(ALL('Sales Data'[Location]),CALCULATE[ATV],,DESC,Skip))

 

This works fine when I put the rank into a table along with ATV and Location, but when I drag the Margin measure into the table the ranking breaks as in the examples below

 

Table Without Margin Measure

 

LocationATVATV Rank
A40.211
B34.662
C32.303
D29.874
E29.755
F29.016
G28.557
H28.308
I27.969

 

 

Table With Margin Measure Added

 

LocationATVATV RankMargin
A40.21163,020.56
B34.66359,880.21
C32.30356,761.30
D29.87453,500.01
E29.75555,750.98
F29.01552,101.04
G28.55650,908.77
H28.30649,890.90
I27.96950,532.65

 

Like I said I've used this exact measure in the same context on other reports and had no issues, to my knowledge measures should never affect other measures when added to a table visual. Would anyone have any insight as to why this is happening? I'm currently pulling my hair out trying to understand what the issue is.

 

Thanks so much in advance

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @Sar_Jo19 ,

ALL used as a filter argument is filter modifier. It removes the filter on its argument.

When the argument is a table, it removes the filter over the entire expanded table (the table specified as argument). Whent the argument is one or more columns, it removes the filters over the specified columns.

In the Measure 2, only the filter existing over 'Sales Data'[Location] is removed

 

You can create a dax using this:

Measure = RANKX(ALL('Sales Data'),CALCULATE(SUM('Sales Data'[ATV])),,DESC,Skip)

If it does not meet the expected results, Can you share sample data and sample output in table format? Or how the Margin Measure is generated, and are there any other columns.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

johnt75
Super User
Super User

As a first step I would use performance analyzer to get a copy of the DAX generated for both versions of the visual - with margin and without. Then have a look at the queries in DAX Studio and see what the differences are.

Although visually you are simply adding another measure it is possible that more is going on behind the scenes, in particular if a filter is being applied to something other than Sales[Location] then that could potentially have an impact

amitchandak
Super User
Super User

@Sar_Jo19 , if you add measure, I do not think rank can change. But it can change if you add column that that is not summarized, Because rank get distributed inside new column

Now, here is a perfect example of unsolliciated reply and why the fabric community is becoming so difficult to find answers.  "...if you add measure, I do not think rank can change...".  @amitchandak , YES, it happens that the rank changes when adding an additional measure.  This community is NOT about opinions, it is about helping someone with a real problem.  And if you do not understand it, then mayne refrain to reply.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.