Forum Discussion

LuciferMstar's avatar
LuciferMstar
Helper I
3 years ago
Solved

Conditional date difference

Hello,   I'm struggling with some comparisons and date difference when I have this kind of data in which some cells are blanks. What do I need to do here is to compare each value in the specified ...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi LuciferMstar 

    You can try the following column

    Days =
    VAR a =
        FILTER ( 'Table', [ID] = EARLIER ( 'Table'[ID] ) )
    VAR b =
        ADDCOLUMNS (
            SUMMARIZE ( FILTER ( a, [Status 1] <> BLANK () ), [Status 1] ),
            "Status 2", MINX ( FILTER ( a, [Status 2] > EARLIER ( 'Table'[Status 1] ) ), [Status 2] )
        )
    VAR c =
        ADDCOLUMNS (
            b,
            "Status 3", MINX ( FILTER ( a, [Status 3] > EARLIER ( [Status 2] ) ), [Status 3] )
        )
    VAR d =
        ADDCOLUMNS ( c, "Dateiff", DATEDIFF ( [Status 2], [Status 3], DAY ) )
    RETURN
        MAXX ( FILTER ( d, [Status 2] = EARLIER ( 'Table'[Status 2] ) ), [Dateiff] )
    

    and the result you have offered the dateiff of 

    25/10/2022 18/11/2022  

    should be 24

     

    Best Regards!

    Yolo Zhu

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