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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

August Carousel

Fabric Community Update - August 2024

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