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
Tymok
Frequent Visitor

DAX measure for Share of Total

Hi,

I am not new to DAX and this is a very simple measure, but for some reason it does not work this time.
I want to calculate to the share of total for every category.
The measure:

Customer rating Share of Total (%) =
DIVIDE(
    [Customer rating count],
    CALCULATE(
        [Customer rating count],
        ALL('Customer Rating'[Rating])
    )
)
Output:
Tymok_0-1756906405770.png

 

For my own sanity I tried it for a different measure, because I know this should work.
Measure:

DELETE Share of Turnover =
DIVIDE(
    [DELETE TEST Turnover],
    CALCULATE(
        [DELETE TEST Turnover],
        ALL('Product Category'[Product category])
    )
)
Output:
Tymok_1-1756906536788.png

As you can see, the measure is basically the same and it works. 

 

Sometimes DAX drives me crazy with it's inconsistencies, can someone please explain why it does not work in the first example?
Thanks

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

I would guess that your customer rating column is sorted by a different column. You need to add that sort by column into the ALL function as well as the rating itself. The sort by column is used in the query behind the table visual, and so that column is in the evaluation context as well as the rating column.

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@Tymok Probably has something to do with your base measure. Would have to see both of them to determine if something in there is the cause. If you avoid CALCULATE you generally don't get these kinds of inconsistencies.

Customer rating Share of Total (%) =
  VAR __Rating = [Customer rating count]
  VAR __AllRating =
    SUMX( 
      ADDCOLUMNS(
        SUMMARIZE( ALL( 'Customer Rating' ), [Rating] ),
        "__Measure", [Customer rating count]
        ),
        [__Measure]
     )
  VAR __Result = DIVIDE( __Rating, __AllRating )
RETURN
  __Result

Bonus, you can troubleshoot it.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
johnt75
Super User
Super User

I would guess that your customer rating column is sorted by a different column. You need to add that sort by column into the ALL function as well as the rating itself. The sort by column is used in the query behind the table visual, and so that column is in the evaluation context as well as the rating column.

Tymok
Frequent Visitor

Thank you, this fixed it.
Never knew sort by different column could have these consequences.

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.