Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
klehar
Helper V
Helper V

Expand a number in a cell to the number of rows

Hi,

 

I have a table

klehar_0-1630075259159.png

 

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.

IDDurationPeriod
ID101100
ID101101
ID101102
ID101103
ID101104
ID101105
ID101106
ID101107
ID101108
ID101109
ID1011010
ID10220
ID10221
ID10222
ID10330
ID10331
ID10332
ID10333

 

 

I want this in M code

 

1 ACCEPTED SOLUTION
Jakinta
Solution Sage
Solution Sage

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"

View solution in original post

1 REPLY 1
Jakinta
Solution Sage
Solution Sage

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"

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors