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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
peterhui50
Helper III
Helper III

Is this possible? DATEINPERIOD not working the way I expected

Hello,

 

I have a dataset here that is linked to a date table.

 

 

 

peterhui50_0-1647023043365.png

 

What I want to do is to do a rolling 12 month addition. 

 

So I created a measure

```

Sales_12_Months =
CALCULATE (
[Sales],
DATESINPERIOD ( DATE_TABLE[Date], LASTDATE ( DATE_TABLE[Date] ), -12, MONTH )
) ```
 
but when I added in the Year, this measure started to work differently than expected. It's likely it is because the year is added, so it filters differently.
 
peterhui50_3-1647023670999.png

 

 

Is this possible? 

 
Thanks!
 
1 ACCEPTED SOLUTION

I just did a SWITCH statement to include an additional column to specify what is "CURRENT PERIOD" vs "PREVIOUS PERIOD" and just did visual level filter. It's a bit easier.

View solution in original post

3 REPLIES 3
littlemojopuppy
Community Champion
Community Champion

Hi @peterhui50 is that first snip your actual dataset?  Because it looks like an Excel pivot table (which summarizes data).  And your rolling 12 month looks correct.

 

 

Looks like this worked
 
Sales_12_Months =
CALCULATE([Sales],DATESINPERIOD(DATE_TABLE[Date],ENDOFYEAR(DATE_TABLE[Date],"2/28"),-12,MONTH))

I just did a SWITCH statement to include an additional column to specify what is "CURRENT PERIOD" vs "PREVIOUS PERIOD" and just did visual level filter. It's a bit easier.

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 MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.