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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
zeppelin77bc
Frequent Visitor

Help with Creating a Measure that FIlters another measure for the last 12 months

Hi,

I am trying to take a measure that sums up customers (sumx) and then shows the last 12 months.

My underlying measure is below
 
Enrollment Count =
VAR MonthStart =
    DATE ( YEAR ( MAX ( 'TimeCalendar'[Date] ) ),
           MONTH ( MAX ( 'TimeCalendar'[Date] ) ), 1 )
VAR MonthEnd   = EOMONTH ( MonthStart, 0 )
RETURN
CALCULATE (
    SUMX ( 'ENR Cube', VALUE ( 'ENR Cube'[Enrolled CT] ) ),

    CROSSFILTER ( 'TimeCalendar'[Date], 'ENR Cube'[Program Start Date], NONE ),

    FILTER (
        ALL ( 'ENR Cube'[Program Start Date], 'ENR Cube'[Program End Date] ),
        'ENR Cube'[Program Start Date] <= MonthEnd
            && COALESCE ( 'ENR Cube'[Program End Date], DATE ( 9999, 12, 31 ) ) >= MonthStart
    )
)
Basically want to create the LTM column from Excel below.  How do I filter the above measure to get my LTM calculation to work correctly? LTM is just a rolling sum of the 12 previous months
DateEnrollment CountLTM 
7/1/2024 0:003075685
8/1/2024 0:00575499
9/1/2024 0:004285681
10/1/2024 0:004285863
11/1/2024 0:004286045
12/1/2024 0:004286227
1/1/2025 0:0010446422
2/1/2025 0:0010446617
3/1/2025 0:0010446812
4/1/2025 0:0010587022
5/1/2025 0:004897150
6/1/2025 0:004937248
7/1/2025 0:002627203
8/1/2025 0:00217167
 
1 ACCEPTED SOLUTION
wardy912
Solution Sage
Solution Sage

Hi @zeppelin77bc 

 

To calculate a Last Twelve Months (LTM) version of your Enrollment Count measure, you’ll want to wrap it in a CALCULATE that filters the date range to the last 12 months based on your TimeCalendar table.

 

Enrollment Count LTM =
CALCULATE (
    [Enrollment Count],
    DATESINPERIOD (
        'TimeCalendar'[Date],
        MAX ( 'TimeCalendar'[Date] ),
        -12,
        MONTH
    )
)

 

--------------------------------

I hope this helps, please give kudos and mark as solved if it does!

 

Connect with me on LinkedIn.

Subscribe to my YouTube channel for Fabric/Power Platform related content!

View solution in original post

4 REPLIES 4
v-sshirivolu
Community Support
Community Support

Hi @zeppelin77bc ,

I would also take a moment to thank @wardy912  , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions

Royel
Impactful Individual
Impactful Individual

Hi @zeppelin77bc  here are some quick fix 

Enrollment Count LTM = 
CALCULATE (
    [Enrollment Count],
    DATESINPERIOD (
        'TimeCalendar'[Date],
        MAX ( 'TimeCalendar'[Date] ),
        -12,
        MONTH
    )
)

Another options 

Enrollment Count LTM = 
CALCULATE (
    [Enrollment Count],
    DATESBETWEEN (
        'TimeCalendar'[Date],
        EDATE(MAX('TimeCalendar'[Date]), -12),
        MAX('TimeCalendar'[Date])
    )
)

Note: Make sure your 'TimeCalendar'[Date] column must be properly formatted as a Date data type and contain continuous dates. 

 

Find this helpful? ✔ Give a Kudo • Mark as Solution – help others too!

wardy912
Solution Sage
Solution Sage

Hi @zeppelin77bc 

 

To calculate a Last Twelve Months (LTM) version of your Enrollment Count measure, you’ll want to wrap it in a CALCULATE that filters the date range to the last 12 months based on your TimeCalendar table.

 

Enrollment Count LTM =
CALCULATE (
    [Enrollment Count],
    DATESINPERIOD (
        'TimeCalendar'[Date],
        MAX ( 'TimeCalendar'[Date] ),
        -12,
        MONTH
    )
)

 

--------------------------------

I hope this helps, please give kudos and mark as solved if it does!

 

Connect with me on LinkedIn.

Subscribe to my YouTube channel for Fabric/Power Platform related content!

Thanks. Those really helped. 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors