Forum Discussion

Puja's avatar
Puja
Helper III
4 years ago
Solved

Duration Calculation

Hello Community, I need some help to calculate the duration based on an event. Based on those highlighted (screenshot below) dates , I need to calculate the duration. Anytime , 9999  or 7777  even...
  • Jihwan_Kim's avatar
    4 years ago

    Hi,

    Please check the below picture and the attached pbix file.

    I tried to create a sample pbix file like below, and it is for creating a new column.

     

     

    Result seconds CC =
    VAR _tableperproductnextdatetime =
        FILTER (
            ADDCOLUMNS (
                ADDCOLUMNS (
                    Data,
                    "@nextdatetime",
                        MINX (
                            FILTER (
                                Data,
                                Data[Product name] = EARLIER ( Data[Product name] )
                                    && Data[DateTime] > EARLIER ( Data[DateTime] )
                            ),
                            Data[DateTime]
                        )
                ),
                "@diff", DATEDIFF ( Data[DateTime], [@nextdatetime], SECOND )
            ),
            Data[Event] IN { 9999, 7777 }
        )
    RETURN
        SUMMARIZE (
            FILTER (
                _tableperproductnextdatetime,
                Data[Product name] = EARLIER ( Data[Product name] )
                    && Data[Event] = EARLIER ( Data[Event] )
            ),
            [@diff]
        )
    
  • Jihwan_Kim's avatar
    Jihwan_Kim
    4 years ago

    Hi,

    Please share your sample pbix file's link, and then I can try to look into it to come up with a solution.