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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
ayoubb
Helper IV
Helper IV

DATEDIFF BETWEEN TWO DATE in order to calculate resolution time

Hello, 

First of all thank you for your support and assistance, 

Please i have this table below: 

DATA BASE.jpg

And i want to calculate the average resolution time in this format "hh:mm:ss" but only for the request number which they have been created between 06h and 19h?

1 ACCEPTED SOLUTION
v-xulin-mstf
Community Support
Community Support

Hi @ayoubb 

Create a measure as:

Measure =

var _table=

SUMMARIZE('Table','Table'[Request number],"start",

var _start=

CALCULATE(

    MAX('Table'[creation date]),

    FILTER(

        ALL('Table'),

        'Table'[Request number]=MAX('Table'[Request number]) && 'Table'[Status]="resolved" && HOUR('Table'[creation date])>6

    )

)



var _end=

CALCULATE(

   MAX('Table'[update date]),

   FILTER(

       'Table',

       'Table'[Request number]=MAX('Table'[Request number]) && 'Table'[Status]="resolved" && HOUR('Table'[update date])<19

   )

)

return DATEDIFF(_start,_end,SECOND)

)

return SUMX(_table,[start])/COUNTROWS(_table)

 

Here is the output:

v-xulin-mstf_0-1610445022245.png

 

Here is the demo, please try it:DATEDIFF BETWEEN TWO DATE in order to calculate resolution time

Best Regards,

Link

View solution in original post

3 REPLIES 3
v-xulin-mstf
Community Support
Community Support

Hi @ayoubb 

Create a measure as:

Measure =

var _table=

SUMMARIZE('Table','Table'[Request number],"start",

var _start=

CALCULATE(

    MAX('Table'[creation date]),

    FILTER(

        ALL('Table'),

        'Table'[Request number]=MAX('Table'[Request number]) && 'Table'[Status]="resolved" && HOUR('Table'[creation date])>6

    )

)



var _end=

CALCULATE(

   MAX('Table'[update date]),

   FILTER(

       'Table',

       'Table'[Request number]=MAX('Table'[Request number]) && 'Table'[Status]="resolved" && HOUR('Table'[update date])<19

   )

)

return DATEDIFF(_start,_end,SECOND)

)

return SUMX(_table,[start])/COUNTROWS(_table)

 

Here is the output:

v-xulin-mstf_0-1610445022245.png

 

Here is the demo, please try it:DATEDIFF BETWEEN TWO DATE in order to calculate resolution time

Best Regards,

Link

Greg_Deckler
Community Champion
Community Champion

@ayoubb If you can post that data as text could provide a specific solution. But, in the mean time here are a number of articles on duration calculations:

(1) Chelsie Eiden's Duration - Microsoft Power BI Community

Duration to Seconds Converter - Microsoft Power BI Community

 

By simply subtracting your two time entries like this ([update date] - [creation date]) * 1. , you will get a decimal value where the integer portion is the number of days and your decimal portion is fractions of a day. So 1/24 hours, 1/60 is minutes, 1/3600 seconds, etc.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

IS this correct:

Column

  1. Average resolution time = CALCULATE(DISTINCTCOUNT('table'[request number]), FILTER('table','table'[status] IN {"resolved"}))

&& DATEDIFF('table'[creation date],'table'[update date],MINUTE)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

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.