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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ale259
Helper I
Helper I

DAX syntax to calculate the percentage of the total

Hello, 
I created the calculate DAX as the picture below, and the result is everyday 100%, which 100% should be the total of the whole week. 

ale259_0-1739395643770.png

Can anyone point out what's wrong with my code? Thank you.

 

1 ACCEPTED SOLUTION

Hi Dino, thank you for your response. It seems that I cannot upload PowerBI up here, so I wonder how to share this file. 

Anyhow, this is my relationship tables:

ale259_1-1739455426360.png

Sum of Visitors = SUM('Daily Visits 2024'[Visitors]

I also create other measures (in total I have 28 measures), such as the Year-over-year that I created after this measure of percentage of total with this syntax: 

YoY% Visitors =
VAR Visitors2024 = [SumofVisitors]
VAR Visitors2023 = SUM('Daily Visits 2023'[Visitors])
return DIVIDE(Visitors2024 - Visitors2023, Visitors2023)

I wonder if my measure Percentage of Total is not working because of this Year-over-year measure that is created afterwards. Thank you 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @ale259 ,

Thanks for bhanu_gautam's reply!
The information you provided is too little. It is unlikely that we can accurately identify the problem based on the existing information.
After testing, there should be no problem with the DAX you provided (if you only have one table):

vjunyantmsft_0-1739419144458.png


The problem should be in your data model or in your measure [SumofVisitors]. Please provide sample data of all the data tables involved, the relationship between the tables, and the DAX used by measure [SumofVisitors] (you can replace your actual data with the test data). Thank you!

Best Regards,
Dino Tao

Hi Dino, thank you for your response. It seems that I cannot upload PowerBI up here, so I wonder how to share this file. 

Anyhow, this is my relationship tables:

ale259_1-1739455426360.png

Sum of Visitors = SUM('Daily Visits 2024'[Visitors]

I also create other measures (in total I have 28 measures), such as the Year-over-year that I created after this measure of percentage of total with this syntax: 

YoY% Visitors =
VAR Visitors2024 = [SumofVisitors]
VAR Visitors2023 = SUM('Daily Visits 2023'[Visitors])
return DIVIDE(Visitors2024 - Visitors2023, Visitors2023)

I wonder if my measure Percentage of Total is not working because of this Year-over-year measure that is created afterwards. Thank you 

bhanu_gautam
Super User
Super User

@ale259 Try using

DAX
PercentOfAllVisitors =
VAR TotalSumVisitors = SUM('Daily Visits 2024'[SumofVisitors])
VAR GrandTotalVisitors = CALCULATE(SUM('Daily Visits 2024'[SumofVisitors]), ALL('Daily Visits 2024'))
RETURN DIVIDE(TotalSumVisitors, GrandTotalVisitors)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Yes I used that and it's now working. Tu.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.