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

Grouping matrix columns using custom measures

Hello,

 

I've been destroying myself trying to figure this out and I wonder if someone can help.

I have the following table (Simplified to get to the root of my problem):

JobProductPriceSaleDate
1A$10001062024
1B$20001062024
2A$11019062024
3C$30018062024
4A$12001052024

 

I would like to display it as follows:

 Today ThisMonth ThisYear 
ProductTotalPriceTotalCountTotalPriceTotalCountTotalPriceTotalCount
A$1101$2102$3303
B00$2001$2001
C00$3001$2001

 

I can flatten the table and created individual measures for every combination of column (e.g. TodayTotalPrice and TodayTotalCount), but I don't want a flat table. I want the nicely structured matrix that can be collapsed and expanded.

 

If anyone could please help for this simple example that would be great. I'm confident I'll be able to expand it to my larger dataset.

 

Thanks.

2 REPLIES 2
DylanSandry
Frequent Visitor

That's worked perfectly thanks!

DylanSandry_1-1718848683669.png

 

Just a follow up question. Is it possible to show and hide certail values based on matrix columns? I want to also add averages after the TotalPrice and TotalCount sections, so it will look like this

 Today ThisMonth ThisYear MonthAverage YearAverage 
ProductTotalPriceTotalCountTotalPriceTotalCountTotalPriceTotalCountPricePerDayCountPerDayPricePerDayCountPerDay

 

I can create the second section of matrix columns with a couple new measures and altered switch statements, but how can I hide the values that dont correspond to that section of the table? (Hide TotalPrice, TotalCount from the MonthAverage and YearAverage sections and vice versa).

 

Cheers.

Daniel29195
Super User
Super User

@DylanSandry 

do the following : 
create a custom table :  ( No need for the Column "Column")

Daniel29195_0-1718788962483.png

 

 
 
add column1 to the matrix. 
and now you just need to create 2 measures : 
TotalPrice
 and 
TotalCount
 
for each measure, use the switch statement :
switch(
true ( ),
   selectedvalue(table[column1]) =  "Today" , calculate( [total price] , date =  today () ,
selectedvalue(table[column1]) =  "This Month" , calculate( [total price] , year(sales[order date]) = year ( today() ,  month(sales[order date]) = month( today()) ,
.........., ,
 
 
 
let me know if this helps. 
 

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.

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.