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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Syndicate_Admin
Administrator
Administrator

Create column with the closest date of the same table considering the IDs

Good afternoon

I'm new to power BI and would like your help with a DAX that does the following:

  1. I have a table with several computers with the start and end dates of their maintenance.
  2. I want to create a column that places the previous maintenance end date (column: PreviusDate) for each computer and for each row.
  3. When the equipment has no previous maintenance, it should be left blank.


Attached data in Excel and Power BI file.

https://1drv.ms/u/s!Ah2kspv1jfcTgbJSmMPQNpqKuAdd5g?e=7tzgCM

Thank you in advance for your help

Best regards

Jesus

1 ACCEPTED SOLUTION
v-xiaosun-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

I wonder whether I have understood your requirement correctly. I think that you need "PreviusDate" for each computer. Here is my suggestion.

You can create a column as below.

column =
CALCULATE (
    MAX ( 'Data'[FIN] ),
    FILTER (
        'Data',
        'Data'[COD NISIRA] = EARLIER ( Data[COD NISIRA] )
            && 'Data'[FIN] < EARLIER ( Data[FIN] )
    )
)

Final output:

vxiaosunmsft_0-1671093031365.png

 

Best Regards,
Community Support Team _ xiaosun

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

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

Thanks a lot! It's what I needed.

v-xiaosun-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

I wonder whether I have understood your requirement correctly. I think that you need "PreviusDate" for each computer. Here is my suggestion.

You can create a column as below.

column =
CALCULATE (
    MAX ( 'Data'[FIN] ),
    FILTER (
        'Data',
        'Data'[COD NISIRA] = EARLIER ( Data[COD NISIRA] )
            && 'Data'[FIN] < EARLIER ( Data[FIN] )
    )
)

Final output:

vxiaosunmsft_0-1671093031365.png

 

Best Regards,
Community Support Team _ xiaosun

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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