Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Getting the previous date before the most recent

Good afternoon,   I would like help extracting the date before the last date registered in a dataset. For instance, i have similar services being realized and i would like to know how long did it t...
  • v-easonf-msft's avatar
    v-easonf-msft
    6 years ago

    Hi,  Anonymous 

    Try steps as below:

    1.create index column "Index" in query Editor and  click "close&apply"

     

    2.Sort ascending by index, and create calculated column " Last Date2" as below:

    (here ,you need to pay attention  to the Data type of your calculate column )

    Last Date2 =
    VAR a =
        CALCULATE (
            MAX ( 'Table'[Index] ),
            'Table',
            'Table'[cod-cilindro] = EARLIER ( 'Table'[cod-cilindro] ),
            'Table'[Index] < EARLIER ( 'Table'[Index] )
        ) + 0
    RETURN
        IF (
            'Table'[Index2] = 0,
            BLANK (),
            CALCULATE (
                SUM ( 'Table'[LAST DATE(ultima data)] ),
                'Table',
                'Table'[Index] = a
            )
        )

     

     

    Here is a demo.

     

    Pbix Attached 

     

    Best Regards,
    Community Support Team _ Eason
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.