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
nebarnes
Frequent Visitor

Using DATESINPERIOD to calculate a rolling 12 month measure

Hi, I am trying to calculate a rolling sickness absence rate over a 12 month period, but only show it for the months of the current financial year (April 2024 shows the total absence rate for May 2023 to April 24, but only April 2024 should be visible on the graph, and so on).

 

I've got the measure working using DATESINPERIOD but when I plot this on a graph, the line extends beyond the currently selected filter period. All the date filter does is adjust the period that the measure works for, leaving a straight line before and after the selected date period.

 

This is the measure:

 

Sick Absence Rolling 12 Months = 
VAR LastSelectedDate = MAX('Calendar'[Date])
VAR TotalSick =
    CALCULATE('People'[Total Sick Days], DATESINPERIOD('Calendar'[Date], LastSelectedDate, -12, MONTH))
VAR TotalDays =
    CALCULATE('People'[Colleague Days], DATESINPERIOD('Calendar'[Date], LastSelectedDate, -12, MONTH))
VAR Result =
    TotalSick/TotalDays
RETURN Result

 

 

This is the result on the graph, I want to filter out the entries either side of the red lines and be left with just the results for months within the last financial year:

 

Screenshot 2024-06-26 105415.png

 

In the pic above, I am using a filter on the main calendar table to select just the current financial year but no matter what I do, I cannot get rid of the before and after lines.

 

This is the model, its nothing complicated. People.Month = Calendar.Date

Screenshot 2024-06-26 105904.png

 

Any help appreciated!

1 ACCEPTED SOLUTION
nebarnes
Frequent Visitor

I fixed it myself. If using Power BI's hierarchical date option, then the lines won't go away no matter what. Changing to standard dates fixed it 😑

View solution in original post

1 REPLY 1
nebarnes
Frequent Visitor

I fixed it myself. If using Power BI's hierarchical date option, then the lines won't go away no matter what. Changing to standard dates fixed it 😑

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