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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
cgm
Frequent Visitor

Matrix with values on rows and dynamic month/year as columns

Is something like this possible?  I'm trying to create a matrix that has about twenty measures on rows and three date columns that change dynamically based on two slicers (month/year "From" and "To"). 

 

The first column needs be the month selected in the "To" slicer.  The second column to be the range between "From" and "To".  The third column to be the previous year range.  Crude mock up of what I am trying to accomplish below...

 

Slicers:

FROM:October 2023TO:July 2024

 

Matrix:

 Jul-24Oct 23 - Jul 24Oct 22 - Jul 23
Hours                 100                    950                1,100
Billings            80,000            640,000            780,000
Write Offs              2,000              30,000              25,000
Collections            75,000            500,000            675,000

 

I currently have one fact table with all the measures and one date table. 

I'm really stuggling to understand how I would even go about this. I have the matrix with all my measures on rows created, but I can't seem to make the columns work the way I want.

2 REPLIES 2
amitchandak
Super User
Super User

@cgm , You need two disconnected Date tables for slicer, and then you need measure like

 

Date Range Using 2 slicer =
var _max = minx(allselected(Date1), Date1[Date])
var _min = maxx(allselected(Date2), Date2[Date])
var _Lmax = eomonth(_max,-12)
var _Lmin = eomonth(_Min,-12)+1

return
calculate(countrows(Table), Filter(Table,(Table[Date] <=_max && Table[Date] >=_min) || (Table[Date] <=_Lmax && Table[Date] >=_Lmin)) )

 

 

This will give both selected range and last year same range 

 

Now instead of creating all the measures use calculation groups and have item like

 

Date Range Using 2 slicer =
var _max = minx(allselected(Date1), Date1[Date])
var _min = maxx(allselected(Date2), Date2[Date])
var _Lmax = eomonth(_max,-12)
var _Lmin = eomonth(_Min,-12)+1

return
calculate(selectedmeasure(), Filter(Table,(Table[Date] <=_max && Table[Date] >=_min) || (Table[Date] <=_Lmax && Table[Date] >=_Lmin)) )

 

You also need consider Matrix Visual Property switch value to rows

 

Abstract Thesis: How to use two Date/Period slicers

https://youtu.be/WSeZr_-MiTg

calculation group authoring| Measure Slicer: https://youtu.be/VfxfJJ0RzvU

Calculation Groups- Measure Slicer, Measure Header Grouping, Measure to dimension conversion. Complex Table display : https://youtu.be/qMNv67P8Go0

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you for the response amitchandak.  I am having trouble with getting the date range to work based on month/year. (its also not working if I just use date).  Can you tell what I am doing wrong from the screenshots below?

 

Two date tables and a fact table:

cgm_0-1721751363235.png

Date Range Using two slicers:

cgm_1-1721751428213.png

If I select the same month in each slicer, the correct data appears (left slicer is from Dim_TIme, right is from Dim_Time2):

cgm_3-1721751846174.png

 

No Data is returned when the same month is not selected in both slicers:

cgm_2-1721751598346.png

 

Helpful resources

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

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.