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.
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:
Goal output:
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.
Solved! Go to Solution.
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
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"
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
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"
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!
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
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"
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
100 | |
54 | |
21 | |
12 | |
11 |