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
WFKoth
Regular Visitor

Time Difference between Rows Grouped by Location, Averaged over Last 7 Days

I'm brand new to BI so please be patient.

 

What I would like to achieve is a rolling average of the time between arrivals of technicians to a location over the previous 7 days.

 

EX: This is the only way i could think to illlustrate this. Not my actual data set. The number in green is what I would like to have on a dashboard.

GeofenceAvg Day 1Avg Day 2Avg Day 3Avg Day 4Avg Day 5Avg Day 6Avg Day 7Avg Wk
Site 18976856

7

Site 2

5647734

5.14

Site 36105789

4

7

       

Region Avg.

6.38

 

Here is the actual data:

GeofenceVehicleDriverDateEntry Time
Site 1U.472/23/20204:09:00 PM
Site 1U.402/23/20206:13:00 PM
Site 2U.382/23/20205:06:00 PM
Site 2 M.062/23/20206:46:00 PM
Site 3U.382/23/20209:52:00 PM
Site 1S.222/24/20203:34:00 PM
Site 2U.282/24/20201:13:00 PM

 

As you can see I need to subract the Entry Time of each row from its successor but only if they are at the same site. When I export this data from the fleet mgmt. software it groups it by site and places the rows in chronologic order. However, I pull the data every 2 days or so ( hopefully everyday soon ), so site information comes in chunks of 1-3 rows at a time.

 

Thanks

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Assume you have date time entry or create by merging date nad time

time diff = datediff(table[Datetime], maxx(filter(table,table[geofencse] = earlier(table[geofencse]) && table[Datetime]<earlier(table[Datetime])),table[Datetime]),Hour)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

Assume you have date time entry or create by merging date nad time

time diff = datediff(table[Datetime], maxx(filter(table,table[geofencse] = earlier(table[geofencse]) && table[Datetime]<earlier(table[Datetime])),table[Datetime]),Hour)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Annotation 2020-02-25 102808.png

 

Thoughts?

 

Geofence is both the name of the table and the "Site" column.

Enter is the name of the date time column you suggested.

Create as new column. Seems like you are creating like new a new measure

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Annotation 2020-02-25 105021.png

 Thank you for being so patient. I am clueless here.

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.