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
jaartz
New Member

Changing Subtotal Aggregations for Measures in a Matrix Visual

Hi everyone,

 

I have a dataset that looks like this:

 

jaartz_0-1659417960807.png

 

This is currently represented in a matrix visual. The subtotal of the first row returns the first value in the row and the subtotal of the last row returns the sum. I'm attempting to return the last value in the last row as the subtotal for that aggregated period. The DAX measure for the first row is CALCULATE(SUM(Fact_Table[Amount]), PREVIOUSMONTH(Dim_Date[Date])) and, I guess because it uses PREVIOUSMONTH, DAX evaluates that to January as the aggregation, which is my desired result. The DAX measure for the last row is simply SUM(Fact_Table[Amount]). I understand that this defaults the aggregation of the subtotal to a sum, but I'm a bit stumped about how to change that aggregation for the subtotal shown to what I'd really like it to be: the last value available in that subtotal period (i.e. $645 should be the subtotal for the last row, not the sum of all values). I've reviewed this post, but that, as expected, returns the max of the month/year in the date table as a whole and the corresponding value. Really all I'm attempting to do is use the last available month in the last column as the aggregation for that subtotal. Any help with this would be greatly appreciated. Thank you!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@jaartz , One option is to use

last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

Why previousmonth does not give result when datesmtd is giving it: https://youtu.be/1KkoJehRVeg

 

 

Another is swich using isinscope

 

if(isinscope (Date[Month Year]) , CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH))) , CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Month)) )

 

https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/

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

2 REPLIES 2
jaartz
New Member

Thank you!

amitchandak
Super User
Super User

@jaartz , One option is to use

last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

Why previousmonth does not give result when datesmtd is giving it: https://youtu.be/1KkoJehRVeg

 

 

Another is swich using isinscope

 

if(isinscope (Date[Month Year]) , CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH))) , CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Month)) )

 

https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/

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

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.