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

Rolling 12 months DAX calculation

Hello,

 

Good Day!

 

I have a requirement to visualize rolling 12 months(last 12 monts from selected in filter) data in bar graph. Please give me a suggetion how can I acheive DAX for that.

 

Please note that, system recognized dates are not available in my data.

 

Here is the sample data:

YearMonthValue
20221100
20222101
20223102
20224103
20225104
20226105
20227106
20228107
20229108
202210109
202211110
202212111
20231112
20232113
20233114
20234115
20235116
20236117
20237118
20238119
20239120
202310121
202311122
202312123
20241124
20242125
20243126
20244127
20245128
20246129
20247130
20248131
20249132
202410133
202411134
202412135
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @sivaadityat 

You can refer to the following solution.

1.Create a slicer table

Slicer = SUMMARIZE('Table',[Year],'Table'[Month])

2.Create a measure

Measure =
VAR a =
    DATE ( MAX ( 'Slicer'[Year] ), MAX ( 'Slicer'[Month] ), 1 )
VAR b =
    EOMONTH ( a, -12 )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            EOMONTH ( DATE ( MAX ( 'Table'[Year] ), MAX ( 'Table'[Month] ), 1 ), 0 ) >= b
                && EOMONTH ( DATE ( MAX ( 'Table'[Year] ), MAX ( 'Table'[Month] ), 1 ), 0 )
                    < EOMONTH ( a, 0 )
        )
    )

vxinruzhumsft_0-1701667325942.png

Best Regards!

Yolo Zhu

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @sivaadityat 

You can refer to the following solution.

1.Create a slicer table

Slicer = SUMMARIZE('Table',[Year],'Table'[Month])

2.Create a measure

Measure =
VAR a =
    DATE ( MAX ( 'Slicer'[Year] ), MAX ( 'Slicer'[Month] ), 1 )
VAR b =
    EOMONTH ( a, -12 )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            EOMONTH ( DATE ( MAX ( 'Table'[Year] ), MAX ( 'Table'[Month] ), 1 ), 0 ) >= b
                && EOMONTH ( DATE ( MAX ( 'Table'[Year] ), MAX ( 'Table'[Month] ), 1 ), 0 )
                    < EOMONTH ( a, 0 )
        )
    )

vxinruzhumsft_0-1701667325942.png

Best Regards!

Yolo Zhu

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

Ashish_Mathur
Super User
Super User

PBI file attached.

Ashish_Mathur_0-1701571166820.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

Your sample data is not usable.

 

lbendlin_0-1701566218328.png

You also need to define what you mean by "last 12 months"  - does that include the currently selected month?

 

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.