March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I have a table
I want to expand the duration column such that if it is 10, then I should get 11 rows starting from 0 to 10 for my column period
If duration = 2 then my period column should have 3 rows 0,1,2
See expected output below.
ID | Duration | Period |
ID101 | 10 | 0 |
ID101 | 10 | 1 |
ID101 | 10 | 2 |
ID101 | 10 | 3 |
ID101 | 10 | 4 |
ID101 | 10 | 5 |
ID101 | 10 | 6 |
ID101 | 10 | 7 |
ID101 | 10 | 8 |
ID101 | 10 | 9 |
ID101 | 10 | 10 |
ID102 | 2 | 0 |
ID102 | 2 | 1 |
ID102 | 2 | 2 |
ID103 | 3 | 0 |
ID103 | 3 | 1 |
ID103 | 3 | 2 |
ID103 | 3 | 3 |
I want this in M code
Solved! Go to Solution.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwVNJRMlWK1QGxjYBsIyjbGMg2h7JNgGxDpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Duration = _t]),
#"Added Custom" = Table.AddColumn(Source, "Custom", each {0..Number.From([Duration])}),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom")
in
#"Expanded Custom"
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwVNJRMlWK1QGxjYBsIyjbGMg2h7JNgGxDpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Duration = _t]),
#"Added Custom" = Table.AddColumn(Source, "Custom", each {0..Number.From([Duration])}),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom")
in
#"Expanded Custom"
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.