Forum Discussion
raveenraveen
3 years agoFrequent Visitor
How to get a dates populate based on prevous row without using index
I have a table as below: Start date | end date | name | alias | 01/01/2022 | 01/01/2024 | raj | bhutan 05/01/2022 | 01/01/2024 | rem | india I need to update the first...
- 3 years ago
Anonymous
Can you please provide a solution using powerquery?
- Anonymous3 years ago
Hi raveenraveen ,
You can use the following code to implement the requirement.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMDJS0lEqSswCkkkZpSWJeUqxOtFKpkhyqblAMjMvJTMRLAUS1jfTNwcKGpanAMmU8kKl2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Start date" = _t, name = _t, alias = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Start date", type date}, {"name", type text}, {"alias", type text}}), test = Table.Sort(#"Changed Type",{{"Start date", Order.Ascending}}), #"Added Custom" = Table.AddColumn(test, "Custom", (x)=> try List.Select(test[Start date],(y)=>y>x[Start date]){0} otherwise null ), #"Changed Type1" = Table.TransformColumns(Table.TransformColumnTypes(#"Added Custom",{{"Custom", type date}}) , {"Custom",(x)=> Date.AddDays(x,-1) } ), #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Custom", "End date"}}), #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"Start date", "End date", "name", "alias"}) in #"Reordered Columns"Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
raveenraveen
3 years agoFrequent Visitor
Anonymous
Can you please provide a solution using powerquery?
Anonymous
3 years agoNot applicable
Hi raveenraveen ,
You can use the following code to implement the requirement.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMDJS0lEqSswCkkkZpSWJeUqxOtFKpkhyqblAMjMvJTMRLAUS1jfTNwcKGpanAMmU8kKl2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Start date" = _t, name = _t, alias = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Start date", type date}, {"name", type text}, {"alias", type text}}),
test = Table.Sort(#"Changed Type",{{"Start date", Order.Ascending}}),
#"Added Custom" = Table.AddColumn(test, "Custom", (x)=> try List.Select(test[Start date],(y)=>y>x[Start date]){0} otherwise null ),
#"Changed Type1" = Table.TransformColumns(Table.TransformColumnTypes(#"Added Custom",{{"Custom", type date}}) , {"Custom",(x)=> Date.AddDays(x,-1) } ),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Custom", "End date"}}),
#"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"Start date", "End date", "name", "alias"})
in
#"Reordered Columns"
Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.