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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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