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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
DennisSchlein
Helper III
Helper III

Gross Profit - Measure - with wrong context

Hi 

Im fairly new to dax - and use chat gpt for a lot of my stuff.
So i'm sorry if I don't have a deeper understanding.

Gross Profit = 
CALCULATE(
    [Sum of Sales] - ([Linehaul Amount Cost] + [Lastmile Amount Cost])
    
)



I have this measure - what I want to use to rank my customers.

Customer GP Rank - TOP 10 = 
RANKX(
    ALL('MDS CG1'[CustomerGroupName]),
    CALCULATE([Gross Profit]),
    ,
    DESC,
    DENSE
)


And this works alright :
image.png
But if I add another dimension, then it stops working.

Not only does it apply 1 to all customers - and not keeping the rank across all Markets:

image.png

1 ACCEPTED SOLUTION
v-dineshya
Community Support
Community Support

Hi @DennisSchlein ,

Thank you for reaching out to the Microsoft Community Forum.

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.


If my response has resolved your query, please mark it as the "Accepted Solution" to assist others. Additionally, a "Kudos" would be appreciated if you found my response helpful.

Thank you

View solution in original post

6 REPLIES 6
v-dineshya
Community Support
Community Support

Hi @DennisSchlein ,

Thank you for reaching out to the Microsoft Community Forum.

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.


If my response has resolved your query, please mark it as the "Accepted Solution" to assist others. Additionally, a "Kudos" would be appreciated if you found my response helpful.

Thank you

Hi @DennisSchlein ,

Thank you for reaching out to the Microsoft Community Forum.

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.


If my response has resolved your query, please mark it as the "Accepted Solution" to assist others. Additionally, a "Kudos" would be appreciated if you found my response helpful.

Thank you

Hi @DennisSchlein ,

Thank you for reaching out to the Microsoft Community Forum.

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.


If my response has resolved your query, please mark it as the "Accepted Solution" to assist others. Additionally, a "Kudos" would be appreciated if you found my response helpful.

Thank you

Ashish_Excel
Super User
Super User

Hi,

Share some data to work with and show the expected result.  Share data in a format that can be pasted in an MS Excel file.

Ritaf1983
Super User
Super User

Hi @DennisSchlein 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
DataInsights
Super User
Super User

@DennisSchlein,

 

Try the RANK function. It's generally preferred over RANKX. You'll need to specify each column in the visual; this example assumes that the second column in the visual is CustomerName.

 

Customer GP Rank - TOP 10 =
RANK (
    DENSE,
    ALLSELECTED ( 'MDS CG1'[CustomerGroupName], 'MDS CG1'[CustomerName] ),
    ORDERBY ( [Gross Profit] ),
    DESC
)

 

https://www.sqlbi.com/articles/introducing-the-rank-window-function-in-dax/ 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors