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 take to return into maintenance, which means, date of sending - compared to the date of return. 

The following figure will describe what i want: to see the previous date of sending (data envio) before the actual date of sending( last sending date) and compare it with returning date to get the time between repairs.

4 Replies

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

    Hi , Anonymous 

    Not very clear .Can you show me more details?

    Sample data/Pbix file  and expected result  will make it easier for us to understand and  solve your problem.

     

    Best Regards,
    Community Support Team _ Eason

    • Anonymous's avatar
      Anonymous
      Not applicable

      Good morning.

       

      Thanks for the fast answer. i will send you a sample for testing.

      What i want: do show the previous date of sending to maintenance of my dataset ( dt-envio) in order to know how long did it took to show the same defect. 

      cod-cilindroLAST DATE(ultima data)SENDING DATE (dt-envio)desc-motivosdesc-servicos
      60933224/10/2019 00:0024/10/2019 00:00Batida/Risco 
      60933209/11/2019 00:0009/11/2019 00:00Conferência Da Arte / RegistroServiço Não Executado
      60933212/11/2019 00:0012/11/2019 00:00Conferência Da Arte / RegistroBater Prova
      60933227/12/2019 00:0027/12/2019 00:00DesgasteRecromo
      60933211/01/2020 00:0011/01/2020 00:00DesgasteGravação
      60933219/02/2020 00:0019/02/2020 00:00DesgasteGravação

       

      the red one should be substituted by the purple one

       

      I can't upload data into the forum. 

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

        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.