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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Tdl1982
Regular Visitor

Return / Lookup next date in a column of Dates

Hi all, 

 

I am new to Power BI and I am trying to create a new column based on date information in another (in Power Query). 

 

I effectively want my next column to display the NEXT date in the column it is referencing. If there is no next date then return TODAYs date. 

Current: 

Tdl1982_0-1627359383507.png

Goal output:

Tdl1982_1-1627359441209.png

 

I have been playing aroud with Dates and List.Max and List.Remove but not getting the output I am looking for. 

 

Any help is greatly appreciated. 

 

Thank you.



 

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Tdl1982 

 

You are only looking at dates regardless of location, here is one way. Please provide sample data in a format which people can copy in the future

Vera_33_0-1627362929759.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUByIjA0NLJR0lR6VYnWglQ1MMISNLJCEnpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Paid = _t, Where = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Paid", type date}, {"Where", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each try #"Added Index"[Paid]{[Index]+1} otherwise Date.From( DateTime.LocalNow()))
in
    #"Added Custom"

 

View solution in original post

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

Hi @Tdl1982 

 

You are only looking at dates regardless of location, here is one way. Please provide sample data in a format which people can copy in the future

Vera_33_0-1627362929759.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUByIjA0NLJR0lR6VYnWglQ1MMISNLJCEnpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Paid = _t, Where = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Paid", type date}, {"Where", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each try #"Added Index"[Paid]{[Index]+1} otherwise Date.From( DateTime.LocalNow()))
in
    #"Added Custom"

 

Tdl1982
Regular Visitor

Hello Vera_33, Thank you for this. Since I posted I worked out using two index tables and then merging together. Your way is even more efficient again. Thank you! 

Vera_33
Resident Rockstar
Resident Rockstar

Hi @Tdl1982 

 

You are only looking at dates regardless of location, here is one way. Please provide sample data in a format which people can copy in the future

Vera_33_0-1627362929759.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUByIjA0NLJR0lR6VYnWglQ1MMISNLJCEnpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Paid = _t, Where = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Paid", type date}, {"Where", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each try #"Added Index"[Paid]{[Index]+1} otherwise Date.From( DateTime.LocalNow()))
in
    #"Added Custom"

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.