Forum Discussion

GeekAlfPro's avatar
GeekAlfPro
Helper V
4 years ago
Solved

TIME COMPARISON

Hi,   i want to calculate the difference between 2 hours (Theorical and real). The trouble is that i have not the day, so i try to test if the hour is after 00:00, but i don't manage to solve my f...
  • rsbin's avatar
    4 years ago

    GeekAlfPro ,

    Wasn't able to find a solution using Power Query, but using DAX, I came up with this:

    Ecarts = IF( [Heure reelle] - [Heure Theorique] > 0,
                 [Heure reelle] - [Heure Theorique],
                 TIME(24,0,0) - [Heure Theorique] + [Heure reelle] )

    Heure TheoriqueHeure reelleEcarts

    23:57:20 00:07:20 23:50:00
    00:01:10 23:59:10 23:58:00
    22:11:05 22:11:35 00:00:30

    If you really need to do this in PQ, perhaps you can try some similar logic.

    Hope this helps.

    Regards,