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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
PowerBI101
Frequent Visitor

How to make a rolling 12-month calculation?

I'm trying to do a 12-month trailing (rolling) calculation of LTIF (Lost Time Incident Frequency) for my report. The calculation formula itself isn't the issue, but I'm having trouble calculating the rolling value of 12 months.


For reference, LTIF is calculated as (Number of injuries)*1000000/(Worked hours)

 

The calculation consists of two relevant tables. First, we have IncidentReports, which contains the incidents. Each incident has a date of occurance, IncidentReports[Date]. I have also made a measure called [LTI] (with COUNTROWS), which calculates the number of incidents. It works correctly and can be used in the LTIF formula.

 

The second table is TimeRecords. Each day has multiple rows for worked hours. The relevant columns are TimeRecords[Date] (for which date this row is) and TimeRecords[Hours] (how many hours this record contains).

 

I also have a Time table. The relevant column is Time[Date], which contains each date. I have relations from IncidentReports[Date] to Time[Date] and TimeRecords[Date] to Time[Date]. I'm aware that this table is needed for the Power BI time intelligence to function, but I'm not sure how.

 

I have searched the Internet and this forum for help regarding this issue, but I haven't been able to correctly calculate the LTIF for each month. Due to the nature of my data (multiple rows for each day of worked hours and one row for each incident), I can't provide sample data. However, I have attached some sample data that I collected from my visual below. I'm unable to calculate the LTIF measure (rolling 12 months) in Power BI, I calculated them by hand. They coul be used in a table visual or a chart visual for example.

 

LTIF.PNG

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @PowerBI101 ,

You can use date function to convert  year month fields to date value and calculate out previous 12 month date, then use convert date value as filter condition to summarize LTIF filed values.

Measure =
VAR currYear =
    MAX ( Table[Year] )
VAR currMonth =
    MAX ( Table[Month] )
RETURN
    CALCULATE (
        SUM ( Table[LTIF] ),
        FILTER (
            ALLSELECTED ( Table ),
            DATE ( [Year], [Month], 1 )
                >= DATE ( [Year] - 1, [Month], 1 )
                && DATE ( [Year], [Month], 1 ) <= DATE ( currYear, currMonth, 1 )
        )
    )

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
chavanr
Resolver I
Resolver I

Hi @Anonymous 

I have a similar measure to calculate 12 months rolling LTIFR, frequency rates.

I have a calculated measure for LTIFR.

 

I have done the below but it is giving me incorrect values.

Rolling 12 Months FR =
VAR sd =
LASTDATE(DATEADD(Dates[Date],-1,YEAR))
RETURN
CALCULATE(
SUMX(
SUMMARIZE(
Dates,
Dates[Year],
Dates[Month],
"LTIG2", 'Frequency Rates'[LTI FR]),'Frequency Rates'[LTI FR]),
 
 
 
FILTER(
ALL( Dates[Date]),
Dates[Date] >sd && Dates[Date] <= MAX(Dates[Date])))
Anonymous
Not applicable

Hi @PowerBI101 ,

You can use date function to convert  year month fields to date value and calculate out previous 12 month date, then use convert date value as filter condition to summarize LTIF filed values.

Measure =
VAR currYear =
    MAX ( Table[Year] )
VAR currMonth =
    MAX ( Table[Month] )
RETURN
    CALCULATE (
        SUM ( Table[LTIF] ),
        FILTER (
            ALLSELECTED ( Table ),
            DATE ( [Year], [Month], 1 )
                >= DATE ( [Year] - 1, [Month], 1 )
                && DATE ( [Year], [Month], 1 ) <= DATE ( currYear, currMonth, 1 )
        )
    )

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.