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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
smore
Advocate I
Advocate I

Add rows to a table based on cell value

MajorGroupMinorGroupSample
163
152

Above is an example of my data table to which I am trying to add the # of samples for each MajorGroup/MinorGroup as rows counting down to 1. An example of the desired output table is seen below. 

----> 

MajorGroupMinorGroupSample
163
162
161
152
151

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You can transform the Sample column (or add a new column) that creates a list {1,2,..,N} and then expand that list column to new rows.

 

AlexisOlson_0-1637595563375.png

 

Here's the full query I used:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIDYmOlWB0IzxSIjZRiYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [MajorGroup = _t, MinorGroup = _t, Sample = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"MajorGroup", Int64.Type}, {"MinorGroup", Int64.Type}, {"Sample", Int64.Type}}),
    #"Number to list" = Table.TransformColumns(#"Changed Type", {{"Sample", each List.Reverse({1.._}), type list}}),
    #"Expanded Sample" = Table.ExpandListColumn(#"Number to list", "Sample")
in
    #"Expanded Sample"

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

You can transform the Sample column (or add a new column) that creates a list {1,2,..,N} and then expand that list column to new rows.

 

AlexisOlson_0-1637595563375.png

 

Here's the full query I used:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIDYmOlWB0IzxSIjZRiYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [MajorGroup = _t, MinorGroup = _t, Sample = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"MajorGroup", Int64.Type}, {"MinorGroup", Int64.Type}, {"Sample", Int64.Type}}),
    #"Number to list" = Table.TransformColumns(#"Changed Type", {{"Sample", each List.Reverse({1.._}), type list}}),
    #"Expanded Sample" = Table.ExpandListColumn(#"Number to list", "Sample")
in
    #"Expanded Sample"

Thanks so much for the help! This worked perfectly. 👍

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.