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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
Community Champion
Community Champion

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



Follow on LinkedIn
@ 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!:
DAX For Humans

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
Community Champion
Community Champion

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



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.