Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Get Date difference with minutes if possible between first occurrence and last occurrence.

In the screenshot attached A has occurred four times and first occurrence is on 01/01/2020 11:20 and last occurrence is 03/01/2020 11:29. So the date difference between these two is 2 days 9 minutes. (1449 min). Calculation difference in hours or in muntes or in seconds will also work.

 

I need result table in Power like 

A  1449

B  X

C  X..

 

  • Anonymous's avatar
    Anonymous
    6 years ago

    Came to know later that simple below measure will also work
    DateDiff in Hours = DATEDIFF(MIN(B),MAX(B),HOUR)

4 Replies

  • You have view data based on column 1

    and create a measure to take diff

     

    measure = datediff(Min(Table[Date]),Max(Table[Date]),Minute)

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

    Hi Anonymous ,

     

    Try this measure:

     

    Measure = 
    VAR Min_ = 
    CALCULATE(
        MIN(Sheet4[Date/time]),
        ALLEXCEPT(
            sheet4, Sheet4[Item]
        )
    )
    VAR Max_ = 
    CALCULATE(
        MAX(Sheet4[Date/time]),
        ALLEXCEPT(
            Sheet4, Sheet4[Item] 
        )
    )
    RETURN
    Measure 2 = 
    DATEDIFF(
        [Min_], [Max_], MINUTE
    )

    2 days 9 mins = 24*60*2 + 9 = 2889

     

     

    Best regards,
    Lionel Chen

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


     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Came to know later that simple below measure will also work
    DateDiff in Hours = DATEDIFF(MIN(B),MAX(B),HOUR)