Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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.

MicrosoftTeams-image (3).png

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

First, Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Second, See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Hi,  @Anonymous 

Try steps as below:

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

73.png

 

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
        )
    )

 

74.png

 

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.

View solution in original post

4 REPLIES 4
v-easonf-msft
Community Support
Community 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
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. 

Hi,  @Anonymous 

Try steps as below:

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

73.png

 

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
        )
    )

 

74.png

 

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.

Greg_Deckler
Super User
Super User

First, Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Second, See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.