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! Request now

Reply
Nikolainoergard
Frequent Visitor

Multiple date filters and evaluations

Hi community

I have a Summary dashboard that should include actual figueres from the selected period, but also include LTM and PLTM figueres based on the same date slicer.

I followed this great article by SQLBI in terms of data model etc.:  https://www.sqlbi.com/articles/show-previous-6-months-of-data-from-single-slicer-selection/, and it only works partly for my needs.
My calc item:

 

 

 

 

VAR NumberOfMonths = 12
VAR ReferenceDate =
    MAX ( 'pbi DimDate'[Calendar_ConsecutiveFiscalPeriod] )
VAR PreviousDates =
    CALCULATETABLE (
        'Previous Date',
        'Previous Date'[Calendar_ConsecutiveFiscalPeriod] > ReferenceDate - NumberOfMonths
            && 'Previous Date'[Calendar_ConsecutiveFiscalPeriod] <= ReferenceDate
    )
VAR Result =
    CALCULATE (
        SELECTEDMEASURE (),
        REMOVEFILTERS ( 'pbi DimDate' ),
        KEEPFILTERS ( PreviousDates ),
        USERELATIONSHIP ( 'pbi DimDate'[Date_Key], 'Previous Date'[Date_Key] )
    )
RETURN
    Result

 

 

 

 


I have two issues:
1.  When applying the Previous Date table and Calc item to the visusal, it returns sales in actual for period and not in LTM aggregation.
2.  The calc. item dosn't support to show both my LTM and PLTM measure on the visual.

This means the Previous date table with relationship works, becuase when i filter on the main date table, it will use that value as the max, and then show last 12 months. 

My LTM calculation: (PLTM is same logic but -12 on _MaxPeriod)

 

 

 

 

Sales LTM = 
VAR _MaxPeriod = MAX('pbi DimDate'[Calendar_ConsecutiveFiscalPeriod])
VAR _MinPeriod = _MaxPeriod - 12
VAR _Result =
    CALCULATE(
        [Sales], 
        REMOVEFILTERS('pbi DimDate'),
            'pbi DimDate'[Calendar_ConsecutiveFiscalPeriod] <= _MaxPeriod &&
            'pbi DimDate'[Calendar_ConsecutiveFiscalPeriod] > _MinPeriod
    )
RETURN
    _Result

 

 

 

 


Any suggestions on how to fix the two errors?

Thanks in advance

2 REPLIES 2
amitchandak
Super User
Super User

@Nikolainoergard , You can try measure like this with help from a date/calendar table

 

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-12,MONTH))

 

Rolling 12 = CALCULATE([Net], WINDOW(-11,REL, 0, REL, ADDCOLUMNS(ALLSELECTED('Date'[Month Year],'Date'[Month Year Sort] ),ORDERBY([Month Year Sort],asc)))

 

 

 

PLTM

Rolling 12 before 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],eomonth(MAX('Date'[Date]),-12),-12,MONTH))

 

Rolling 12 before 12 = CALCULATE([Net], WINDOW(-23,REL, -12, REL, ADDCOLUMNS(ALLSELECTED('Date'[Month Year],'Date'[Month Year Sort] ),ORDERBY([Month Year Sort],asc)))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello. Thank you for your reply, unfortunately it does not solve my problem @amitchandak 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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