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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
deloittetester
Regular Visitor

next 12 months on matrix

I have a matrix that shows text value based on a measure for each month. If slicer is selected, it drills down to the selected month. Say, if in slicer, 2023 feb is selected, it will show data for 2023 jan. 
Now i want to show in matrix, next 12 months data. i.e., 2023 jan, 2023 mar ... 2024 jan in column

deloittetester_1-1736434351819.png

#needhelp

 

5 REPLIES 5
v-xianjtan-msft
Community Support
Community Support

Hi @deloittetester 

 

I tested it with simple data and here is my solution, hope it works for you.

1. Create a calendar table disconnected from the data table

CalendarTable = ADDCOLUMNS(
    CALENDAR(MIN('Table'[Date]), MAX('Table'[Date])),
    "Year", YEAR([Date]),
    "Month", FORMAT([Date], "MMMM"),
    "Day", DAY([Date]),
    "SortMonthNumber", MONTH([Date])
)

2. Create two slicers with the "Year" and "Month" fields of the CalendarTable.

3. Create the following measures:

InSelectedRange = 
VAR SelectedYear = SELECTEDVALUE('CalendarTable'[Year])
VAR SelectedMonth = SELECTEDVALUE('CalendarTable'[Month])
VAR SelectedYearMonth = SelectedYear * 100 + MONTH(DATEVALUE("1 " & SelectedMonth & " " & SelectedYear))
VAR EndYearMonth = SelectedYearMonth + 100
VAR CurrentYearMonth = YEAR(MAX('Table'[Date])) * 100 + MONTH(MAX('Table'[Date]))
RETURN
IF(CurrentYearMonth > SelectedYearMonth && CurrentYearMonth <= EndYearMonth, 1, 0)
CorrectValue = IF([InSelectedRange] = 1, [Value], BLANK())
// [Value] is a measure for text value

4. Create a Matrix visual with "Year" as the Rows, "Month" as the Columns, and the measure [CorrectValue] as the Values("Year" and "Month" filelds from fact data Table). And set the background color conditional format for the measure.

vxianjtanmsft_0-1736488220358.png

Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi Jarvis, Thank you but i have another field for rows, and 2024 jan should come next to dec 2023

Hi @deloittetester 

 

Please provide sample data that completely covers your problem and describe the fields you used in your matrix visual as well as the measures. It would be nice to provide pbix files if possible. (Please remove privacy information)

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

 

Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

deloittetester
Regular Visitor

Not working. Also, i need to show in matrix, the monthname should be in column. value is a string

123abc
Community Champion
Community Champion

Plz follow bwlow community solution .. hopefully will help you to solve the issue:

 

How to create a matrix with12 months of rolling/trailing data in Power BI

Solved: How to create a matrix with12 months of rolling/tr... - Microsoft Fabric Community

 

I hope this helps!
If you found this answer helpful:

Mark it as the solution to help others find it faster.
Give it a kudo to show your appreciation!
Thank you for being an awesome community member!

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors