- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 row enddate column based on second row startdate.
As the dates successive dates are inclusive.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @raveenraveen ,
According to your description, here are my steps you can follow as a solution.
(1)We can create a calculated column.
End date =
var a=CALCULATE (
MIN ( 'Table'[Start date] ),
FILTER (
'Table',
'Table'[Start date]> EARLIER ( 'Table'[Start date])
)
)
return IF(a<>BLANK(),a-1,BLANK())
(2)Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - January 2025
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
Subject | Author | Posted | |
---|---|---|---|
03-12-2024 04:00 AM | |||
05-30-2024 05:21 AM | |||
Anonymous
| 04-17-2023 02:31 PM | ||
02-08-2024 03:09 PM | |||
08-13-2024 10:02 AM |
User | Count |
---|---|
102 | |
74 | |
42 | |
39 | |
30 |
User | Count |
---|---|
161 | |
87 | |
64 | |
46 | |
42 |