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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
SimonGoldPPG
Frequent Visitor

Grand total not showing the correct value when using SUMX and Countrows

I'm having trouble getting the correct value in the Grand Total using the below Measure. 

 

Facility Active Days:=
SUMX('Facility Region', COUNTROWS(DISTINCT('Global Daily Census'[CensusDate])))

 

Facility Region is a dimension table with a one to many relationship to Global Daily Census. 

I expect the measure to itirate the Faciility Region table, and count the distinct Date values for each facility and sum up the results. 

the results display correctly when using the facilitiy names in the rows and each facility displayes the correct ammount of Unique date, However the grand total simply displays a multiplication of the total rows in the facility region table, times the largest unique count of the date column. 

 

My model is built in SSAS tabular and the below is an excel snip of the result. 

The Grand Total for Facility Active Days should have been 150, but it is displaying 186.

 

SimonGoldPPG_0-1602194682448.png

 

Thanks,

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@SimonGoldPPG , Assuming your row label is region, Try like

 

SUMX(values('Facility Region'[Region]), calculate(COUNTROWS(DISTINCT('Global Daily Census'[CensusDate]))))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@SimonGoldPPG , Assuming your row label is region, Try like

 

SUMX(values('Facility Region'[Region]), calculate(COUNTROWS(DISTINCT('Global Daily Census'[CensusDate]))))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Adding Calculate worked. 

 

Thanks,

 

v-yiruan-msft
Community Support
Community Support

Hi @SimonGoldPPG ,

Please update the formula of measure [Facility Active Days] as below and check if you can get the correct grand total values:

Facility Active Days :=
SUMX (
    VALUES ( 'Facility Region'[Facilitiy Name] ),
    COUNTROWS ( DISTINCT ( 'Global Daily Census'[CensusDate] ) )
)

You can also refer the methods in the following links to resolve it.

Why Your Total Is Incorrect In Power BI - The Key DAX Concept To Understand

Obtaining accurate totals in DAX

Dax for Power BI: Fixing Incorrect Measure Totals

If you still can't get the correct result, please provide some sample data in your model(exclude sensitive data).

Best Regards

Rena

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.