We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hey guys,
I have a sample data
and I am trying to bring in additional rows for every month in between the start date and close date.
something like this:
Please help!!!
Solved! Go to Solution.
Hello @Anonymous
check out this approach. Uses Table.TransformRows to make duplicates of your rows, and apply then needed changes. Afterwards the data is transformed back from a list of records to a table.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIy0DMw1DMyADKNgUxTCNPQAAiAdE5+cYlSrE60khOQY2CpZ2AEk9cDIoguU4jS/ILUPKXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Customer = _t, #"Start Date" = _t, #"Close date" = _t, Amount = _t, Status = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer", type text}, {"Start Date", type date}, {"Close date", type date}, {"Amount", Int64.Type}, {"Status", type text}}, "de-DE"),
TransformRows= Table.TransformRows
(
#"Changed Type",
(row)=>
let
HoOftenDuplicate = Number.RoundDown(Duration.TotalDays(row[Close date]- row[Start Date])/30, 0),
Duplicate = List.Transform(List.Numbers(0, HoOftenDuplicate), (translist)=> Record.TransformFields(row, {{"Start Date", each Date.AddMonths(_, translist)}}))
in
Duplicate
),
CreateFinalTable = Table.FromRecords(List.Combine(TransformRows))
in
CreateFinalTable
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Hello @Anonymous
check out this approach. Uses Table.TransformRows to make duplicates of your rows, and apply then needed changes. Afterwards the data is transformed back from a list of records to a table.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIy0DMw1DMyADKNgUxTCNPQAAiAdE5+cYlSrE60khOQY2CpZ2AEk9cDIoguU4jS/ILUPKXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Customer = _t, #"Start Date" = _t, #"Close date" = _t, Amount = _t, Status = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer", type text}, {"Start Date", type date}, {"Close date", type date}, {"Amount", Int64.Type}, {"Status", type text}}, "de-DE"),
TransformRows= Table.TransformRows
(
#"Changed Type",
(row)=>
let
HoOftenDuplicate = Number.RoundDown(Duration.TotalDays(row[Close date]- row[Start Date])/30, 0),
Duplicate = List.Transform(List.Numbers(0, HoOftenDuplicate), (translist)=> Record.TransformFields(row, {{"Start Date", each Date.AddMonths(_, translist)}}))
in
Duplicate
),
CreateFinalTable = Table.FromRecords(List.Combine(TransformRows))
in
CreateFinalTable
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Thanks a lot. Thats of great help.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 10 | |
| 9 | |
| 7 | |
| 7 | |
| 5 |