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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Pandadev
Post Prodigy
Post Prodigy

Get arrival time from previous row add 5 minutes and add to next row depart time

Hi I have a table of data with blanks that need to be filled in from the previous row

The original table looks like this

Origin                 Destination           Depart        Arrival             Code 
Kodiak                Kitoi Bay               11:00AM     11:25AM         501 
                           Seal Bay                                   11:45AM         511
                           Port William                             12:25PM         521

 

I need to fill in the blanks Origin by adding the previous destination and then I need to fill in the blank depart by previous arrival + 5 mins

This is how the output should look

 

Origin                 Destination           Depart        Arrival             Code 
Kodiak                Kitoi Bay               11:00AM     11:25AM         501 
Kitoi Bay             Seal Bay                11:30AM     11:45AM         511
Seal Bay             Port William          11:50AM     12:25PM         521

1 ACCEPTED SOLUTION
AlexanderPrime
Solution Supplier
Solution Supplier

Assuming your table is called Table1 (Replace Table1 with your table name in all the code below)

IN POWER QUERY (Transform Data)


First you'll need to make an index column within PowerQuery/Transform Data so DAX will know how to declare an order.

Then add a custom column, call it NextDepart and add the following code

[Arrival] + #duration(0,0,5,0)

Then set this new column to be in the "TIME" data format.

 

Exit out of Power Query, (close and apply)
IN DAX

Make 2 columns to replace Origin and Depart with the following DAX code:

 

Origin2 =
VAR PreviousDestination = CALCULATE(MAX(Table1[Destination]),FILTER(Table1,Table1[Index]=EARLIER(Table1[Index])-1))
RETURN
IF((Table1[Origin]=""),PreviousDestination,Table1[Origin])
 
Depart2 = VAR PreviousArrival = CALCULATE(MAX(Table1[NextDepart]),FILTER(Table1,Table1[Index]=EARLIER(Table1[Index])-1))
RETURN
IF(ISBLANK(Table1[Depart]),(PreviousArrival),Table1[Depart])
 
AlexanderPrime_0-1650618972645.png

 

 

Note: For Origin2. If it's not populating correctly. replace IF((Table1[Origin]="") in the code with (ISBLANK(Table1[Origin])

 

 

 


Please note - I am not affiliated with Microsoft, I'm just an end user like yourself.
Just a regular guy doin' Data Science.

If my post has helped you, please don't forget to thumbs up or click "Accept as solution" if it solved your problem!

View solution in original post

2 REPLIES 2
AlexanderPrime
Solution Supplier
Solution Supplier

Assuming your table is called Table1 (Replace Table1 with your table name in all the code below)

IN POWER QUERY (Transform Data)


First you'll need to make an index column within PowerQuery/Transform Data so DAX will know how to declare an order.

Then add a custom column, call it NextDepart and add the following code

[Arrival] + #duration(0,0,5,0)

Then set this new column to be in the "TIME" data format.

 

Exit out of Power Query, (close and apply)
IN DAX

Make 2 columns to replace Origin and Depart with the following DAX code:

 

Origin2 =
VAR PreviousDestination = CALCULATE(MAX(Table1[Destination]),FILTER(Table1,Table1[Index]=EARLIER(Table1[Index])-1))
RETURN
IF((Table1[Origin]=""),PreviousDestination,Table1[Origin])
 
Depart2 = VAR PreviousArrival = CALCULATE(MAX(Table1[NextDepart]),FILTER(Table1,Table1[Index]=EARLIER(Table1[Index])-1))
RETURN
IF(ISBLANK(Table1[Depart]),(PreviousArrival),Table1[Depart])
 
AlexanderPrime_0-1650618972645.png

 

 

Note: For Origin2. If it's not populating correctly. replace IF((Table1[Origin]="") in the code with (ISBLANK(Table1[Origin])

 

 

 


Please note - I am not affiliated with Microsoft, I'm just an end user like yourself.
Just a regular guy doin' Data Science.

If my post has helped you, please don't forget to thumbs up or click "Accept as solution" if it solved your problem!

Thankyou , the code worked perfectly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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