Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount 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"