Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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"
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.