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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
taskinosurname
Frequent Visitor

Rolling Total w/ Uneven Columns

Hello Everyone,

I'm still getting a hang of Dax, and every now and then I run into issues I haven't been able to find online. I'm hoping for a little assistance. My goal is to create a rolling collision rate (per 100,000 KM). Of course, this was easy in excel, but the issue I'm having with Dax is that it's giving me random numbers before March 2021 (i.e. please see columns "R12MDistance"). The Dax I used for each column were:

 

R12MDistance = 
Var _MaxDate = MAX('Date'[Date])
Var Result =
    CALCULATE(
        [TotalMonthlyDistance], 'Date'[Date] <= _MaxDate,
        ALL('Date')
    )
Return
Result
R12MDistance v2 = 
VAR MaxDate = MAX('Date'[Date])    
VAR MinDate = EDATE(MaxDate, -12)   
VAR Result = 
     CALCULATE(
          [TotalMonthlyDistance],
          FILTER(ALL('Date'),    
          'Date'[Date] <= MaxDate &&  
          'Date'[Date] > MinDate)  
     )
RETURN
     Result
R12MDistance v3 = 
CALCULATE(
[Total Monthly Distance], DATESINPERIOD('Date'[Date], MAX('Date'[Date]),-12,MONTH)
)

 

Since there are no recorded KM before March 2021, what I want is for the first distance running total to be  567564 KM then start adding the months after.

 

Ultimately the formula would end up looking like this:

 

 

R12MCollisionRate =
Divide([R12MPreventable],[R12MDistance])*100000

 

Below is a snippet of the data I'm working with. Thank you for your time and assistance.

 

YearMonthPreventableWithZeroR12MPreventableTotalMonthlyDistanceR12MDistanceR12MDistance v2R12MDistance v3
2020April119 2527252  
2020May219 2617511  
2020June120 2707770  
2020July424 2798029  
2020August124 2888288  
2020September024 2978547  
2020October122 3068806  
2020November019 3159065  
2020December117 3249324  
2021January015 3339583  
2021February213 3429842  
2021March11456756425655097124864086810768
2021April013515028469140402381702412991104
2021May011481293678199043440547018766620
2021June010516411911633104784680824963552
2021July064596901131005355587969230479832
2021August054458341353474766568804035829840
2021September054693381595437657601347641461896
2021October044367201831783028562131646702536
2021November0448163020979704910059068452482096
2021December0343359923507356810575635457685284
2022January1440465725979912711465880862541168
2022February4639831528501690012903181767320948
2022March0551061431675855213465524666637548

 

0 REPLIES 0

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.

August 2025 community update carousel

Fabric Community Update - August 2025

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