Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

DATEDIFF with filter

Hallo everybody,   I have a table that looks something like this, Job old status new status old date 115728 o TG 18-1-2018 115728 TG B 2-3-2018 115728 B A 2-3-2018 200 ...
  • Anonymous's avatar
    Anonymous
    6 years ago

     

    This code does exactly what you need it to do.

     

    Previous Date =
    VAR PreviousRow =
        TOPN (
            1;
            FILTER (
                Blad1;
                Blad1[old date] < EARLIER ( Blad1[CRH_REQDATE] )
                    && Blad1[job] = EARLIER ( Blad1[job] )
            );
            Blad1[old date]; DESC
        )
    VAR PreviousValue =
        MINX ( PreviousRow; Blad1[old date] )
    RETURN
        DATEDIFF ( PreviousValue; Blad1[old date]; DAY )

     

    If this reply solved your issues be sure to mark it as the solution.