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
xmunchedx
New Member

How to find average time lost between two tables of dates

Hi there,

 

I'm totally new to Power BI but have been tasked with finding the average time lost between two points of time in a project (ie: time the project began versus when we finished.) It is however a list of projects so there are a lot of dates. I also have to find these averages for three specific time periods to be displayed as a % independent of one another. 

 

The tables have 4 columns: Year, Quater, Month, Day. I've been trying to figure out how to do this for so long and just can't get it so any help is appreciated! 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Your solution is so great bhanu_gautam

Hi, @xmunchedx 

 

Based on your description, I used the following example dataset:

vjianpengmsft_0-1739430826939.png

 

If your start date and end date are in two tables and exist in the form of year, month, and date, you need to create a column in each of the two tables:

StartDate
EndDate
startdate1 = DATE('Table'[Year],'Table'[Month],'Table'[Day])

vjianpengmsft_3-1739431397365.png

End date = DATE('Table2'[Year],'Table2'[Month],'Table2'[Day])

vjianpengmsft_4-1739431456356.png

Next, get the end date in table1:

Enddate1 = 
VAR _project_id = 'Table'[ProjectID]
RETURN 
CALCULATE(MAX('Table2'[End date]),'Table2'[ProjectID]=_project_id)

vjianpengmsft_5-1739431747383.png

Then use the following processing method for the following two columns to find the average and percentage.

First, use the following expression to create a calculated column that will be used to find the number of days of lost time from the start to the end of the project:

time lost = DATEDIFF('Table'[StartDate],'Table'[EndDate],DAY)

vjianpengmsft_1-1739430900799.png

Next, create the following three measures:

Average time lost = AVERAGE('Table'[time lost]) 
Total Time Lost = CALCULATE(SUM('Table'[time lost]),ALL('Table'))
Percentage = DIVIDE([Average time lost],[Total Time Lost])

Finally, in the Table visual, the result is as follows:

vjianpengmsft_2-1739431022861.png

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Your solution is so great bhanu_gautam

Hi, @xmunchedx 

 

Based on your description, I used the following example dataset:

vjianpengmsft_0-1739430826939.png

 

If your start date and end date are in two tables and exist in the form of year, month, and date, you need to create a column in each of the two tables:

StartDate
EndDate
startdate1 = DATE('Table'[Year],'Table'[Month],'Table'[Day])

vjianpengmsft_3-1739431397365.png

End date = DATE('Table2'[Year],'Table2'[Month],'Table2'[Day])

vjianpengmsft_4-1739431456356.png

Next, get the end date in table1:

Enddate1 = 
VAR _project_id = 'Table'[ProjectID]
RETURN 
CALCULATE(MAX('Table2'[End date]),'Table2'[ProjectID]=_project_id)

vjianpengmsft_5-1739431747383.png

Then use the following processing method for the following two columns to find the average and percentage.

First, use the following expression to create a calculated column that will be used to find the number of days of lost time from the start to the end of the project:

time lost = DATEDIFF('Table'[StartDate],'Table'[EndDate],DAY)

vjianpengmsft_1-1739430900799.png

Next, create the following three measures:

Average time lost = AVERAGE('Table'[time lost]) 
Total Time Lost = CALCULATE(SUM('Table'[time lost]),ALL('Table'))
Percentage = DIVIDE([Average time lost],[Total Time Lost])

Finally, in the Table visual, the result is as follows:

vjianpengmsft_2-1739431022861.png

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

When I try the very first formula you gave me, it tells me I cannot convery value "November" of type Text to type integer even though the original column of dates has no text or "November" as its in mm/dd/yyyy form.

bhanu_gautam
Super User
Super User

@xmunchedx 

Create a new column in each table that combines the Year, Quarter, Month, and Day into a single date column. You can do this using the DATE function in Power BI's Data View.

 

For example, if your table is named StartDates and has columns Year, Quarter, Month, and Day, you can create a new column called StartDate:

 

StartDate = DATE(StartDates[Year], StartDates[Month], StartDates[Day])
Do the same for the end dates table:

 

EndDate = DATE(EndDates[Year], EndDates[Month], EndDates[Day])


Merge Tables: Merge the two tables based on a common key to have both start and end dates in a single table. You can do this in Power Query Editor.

 

Select the common key column in both tables and choose the type of join .


Calculate Time Lost: Create a new column in the merged table to calculate the time lost between the start and end dates. You can use the DATEDIFF function to calculate the difference in days, months, or years.

 

 

TimeLost = DATEDIFF(MergedTable[StartDate], MergedTable[EndDate], DAY)


Calculate Average Time Lost: Create a measure to calculate the average time lost.

 

AverageTimeLost = AVERAGE(MergedTable[TimeLost])

 

To calculate the averages for specific time periods (e.g., by Year, Quarter, Month), you can create additional measures or use slicers/filters in your report.

For example, to calculate the average time lost for a specific year:

AverageTimeLostByYear = CALCULATE(
AVERAGE(MergedTable[TimeLost]),
MergedTable[Year] = SELECTEDVALUE(MergedTable[Year])
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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 Kudoed Authors