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
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
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
chavanr
Resolver I
Resolver I

Hi @v-shex-msft 

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])))
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.