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
MagikJukas
Resolver III
Resolver III

Matrix aggregating totals

Hello,

I want to aggregate values at higher level: the formula below works fine, except for the red part where I am trying to aggregate the values:

PD proj test = 

VAR tab=CALCULATE([Qty x Price],FILTER(ALLSELECTED('Date list'[Date]),'Date list'[Date]<=MAX('Date list'[Date])))+0

VAR tab2=IF(tab<0,tab)

VAR tab3=ADDCOLUMNS(CROSSJOIN(VALUES(Data[Material]),VALUES('Date list'[Date])),"tot",tab2)

RETURN IF(ISINSCOPE('Date list'[Date]),IF(ISINSCOPE(Data[Material]),tab2,CALCULATE(SUMX(tab3,[tot]),VALUES('Date list'[Date]))))

 

As you can see from this snapshot, the total is not matching:

MagikJukas_0-1674566359186.png

I know it is a common problem, I have been reading some posts, but I am not making much progress.

 

thank you

2 REPLIES 2
amitchandak
Super User
Super User

@MagikJukas , This formula is enough if you are using date list table in visual and slicer and it marked as date table

 


CALCULATE([Qty x Price],FILTER(ALLSELECTED('Date list'[Date]),'Date list'[Date]<=MAX('Date list'[Date])))+0

 

assuming [Qty x Price] is a measure and you are creating a new measure

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

You can also explore window function

Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

unfortunately, the formula does not aggregate correctly. I need to show the negative values at the lowest level, and aggregate the latter at subtotal level.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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