Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register 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!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.