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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.