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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

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

This is my input file, having more than 24 months and more than a dozen countries of data. 

R_S-13697_0-1622265871880.png

 

Now I want to create a matrix in the PBIX, with 12 months of trailing data from a date slicer.

That is, I will have a date slicer and I would like to see the previous 12 months of data from the selected month.

For example, if I select Jan'21 in my slicer I want the matrix to have data from Jan'21 to Feb'20(12 months) and if I select Nov'20 I want the matrix to show data from Nov'20 to Oct'19(12 months). 

 

 

R_S-13697_2-1622266095889.png

 

I have tried implementing this in Table visual and it works fine in table visual. It even works in the matrix till I don't have rows, as soon as I drag the Class column in the Rows section it does not work. 

Thank you. Any help would be appreciated.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

3 REPLIES 3
Anonymous
Not applicable

This video  helped me.

Thanks.

v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

 

Try the following formula:

 

Measure = 
var SelectDate = MAX('Calendar'[Date])
var RollingMonths = 
    CALCULATETABLE(
        DISTINCT('Calendar'[Month-Year]),
        FILTER(
            ALL('Calendar'),
            'Calendar'[Date] <= SelectDate
            && 'Calendar'[Date] > EOMONTH(SelectDate,-12)
        )
    )
return 
    COUNTROWS(
        INTERSECT(
            RollingMonths,
            DISTINCT('Table'[Date])
        )
    )

 

Then filter Date column in matrix by Measure.

image.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

Fowmy
Super User
Super User

@Anonymous 

Refer to the video from sqlbi.com:
https://www.youtube.com/watch?v=d8Rm7dwM6gc&t=1s

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors