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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bgepps
Frequent Visitor

Create a column to calculate average time difference

Hi guys,

 

I am struggling with a problem calculating average days/times in Power BI Desktop.

 

I have the following sets of data;

 

  • Job status
  • Status start date (date/hh/mm/ss)
  • Status end date (date/hh/mm/ss)

My aim is to find a formula/s which will help me calculate;

 

  • The time intervals spent between different job status'
  • The average time spent on each job status

Does anyone know the steps, or the DAX formula's that i can use to calculate these sets of information? 

 

Thanks!

 

1 ACCEPTED SOLUTION

Hi @bgepps,

 

Please see the screenshot below, click the table visualization, select the Status, Diff and Average measure as Values level. You will get the expected result.

 

Capture1.PNG


Best Regards,
Angelia

View solution in original post

3 REPLIES 3
v-huizhn-msft
Employee
Employee

Hi @bgepps,

 

Based on your description, I try to create sample data and reproduce your scenario, I get the expected result as follows.

 

Create sample data.


 1.PNG


Create calculate column to get the time intervals spent for each status.

 

Diff = DATEDIFF(Table5[Start Date],Table5[End Date],HOUR)


 2.PNG

Create a measure to calculate the average time spent on each job status. Create table to show the result.

Average = DIVIDE(CALCULATE(SUM(Table5[Diff]),ALL(Table5)),CALCULATE(DISTINCTCOUNT(Table5[Status]),ALL(Table5[Status])))

3.png
 
If this is what you want, please share the sample data for further analysis.


Best Regards,
Angelia

Hi Angelia,

 

Thanks for your help with this, it looks promising so far.

 

Once i have added the measure, how do i produce the table like your example below? Apologies, bit of a BI beginner!

 

Appreciate your help,

 

Ben

Hi @bgepps,

 

Please see the screenshot below, click the table visualization, select the Status, Diff and Average measure as Values level. You will get the expected result.

 

Capture1.PNG


Best Regards,
Angelia

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors