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

Total for Top grouping in a matrix not calculating correctly

Hi, 

I wonder if someone can help me with the DAX for a Measure.  
I have a target field in a Matrix that doesn't seem to be calculating correctly.  See below
In the first level grouping the values are correct, but not in the top grouping or for the grand total.   

angelo2022_0-1687321398205.png

The Target is a running total for the month grouped by Program, so should be the sum of all the Target values in the top level group and for the grand total. 

The DAX I'm using is fairly simple.  Uses 2 measures.

[TargetWholeNumber] = SUMX(DISTINCT(DimDate[MonthName]), FIRSTNONBLANK(MeasureData[Target], 0))


This is the measure that I'm using in the matrix. 
[TargetWholeNumberRunningTotal] = CALCULATE([TargetWholeNumber], DATESYTD(DimDate[DateValue], "30/06"))

 

Any advise will be appreciated. 

Cheers,

3 REPLIES 3
Martin_D
Super User
Super User

[TargetWholeNumber] = SUMX(DISTINCT(DimDate[MonthName]), FIRSTNONBLANK(MeasureData[Target]0))

 

Using FIRSTNONBLANK you add only one value per month to the total. Thus, in the grand total rows, the total can only be the sum of one subcatrgory, not of all.

 

What about wrting

 

[TargetWholeNumber] = SUM(MeasureData[Target])

 

instead?

Thanks for your reply, but using the Sum won't work.   The target amount is repeated for each measure values. Using a sum will multiple the target amount.   I just need to find a way to sum up the group values and grand total amount.   

What about setting a month filter on the visual in addition?

Helpful resources

Announcements
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.