Forum Discussion

HenryJS's avatar
HenryJS
Icon for Post Prodigy rankPost Prodigy
6 years ago
Solved

Calculating Time from Start & End Times

Hi all,

 

How can I calculate the hours between two start / end times? The below formula does not calculate the hours correcly

 

Engage Hours per day = ([Start]-[End])

 

  • Hi HenryJS ,

     

    You could use Time.Hour() in query editor.

    if [Start]>[End] then
    24-Time.Hour([Start])+Time.Hour([End])
    else Time.Hour([End])-Time.Hour([Start])

    Here is the result.

     

     

  • Hi HenryJS ,

     

    Does that make sense? If so kindly mark my answer as a solution to close the case. Thanks in advance.

     

16 Replies

  • HenryJS try this expression

     

    Column = DATEDIFF ( [Column1], [Column2], HOUR)

     

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

  • v-eachen-msft's avatar
    v-eachen-msft
    Icon for Community Support rankCommunity Support

    Hi HenryJS ,

     

    You could use Time.Hour() in query editor.

    if [Start]>[End] then
    24-Time.Hour([Start])+Time.Hour([End])
    else Time.Hour([End])-Time.Hour([Start])

    Here is the result.

     

     

  • v-eachen-msft's avatar
    v-eachen-msft
    Icon for Community Support rankCommunity Support

    Hi HenryJS ,

     

    Does that make sense? If so kindly mark my answer as a solution to close the case. Thanks in advance.