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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
pfInigo
Frequent Visitor

Convert a list of numbers into a another list

Hi,

 

I have a problem I can't figure out.

I have a table of numbers attributable to an ID, that I want split out based on the value in one of the columns (Count).

The following is what I have and what I want:

Current:   
IDOrderCountValue
1120.5
1211
1320
    
Desired:   
IDOrderCountValue
1110.5
1210.5
1311
1410
1510

 

Any help is much appreciated, thanks,

Paul

1 ACCEPTED SOLUTION

Thank you for this!

I used a very similar method to get my solution:

....

#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Sorted Rows2", {"fk_LayerId", "order", "value"}, "Attribute", "Value.1"),
    #"Added Custom" = Table.AddColumn(#"Unpivoted Other Columns", "Custom", each Table.Repeat(Table.FromRecords({[Col1=1]}),[Value.1])),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Col1"}, {"Col1"}),
    #"Removed Columns1" = Table.RemoveColumns(#"Expanded Custom",{"Attribute", "Value.1"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns1",{{"Col1", "Count"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Count", Int64.Type}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Changed Type1",{"fk_LayerId", "order", "Count", "value"}),
    #"Grouped Rows" = Table.Group(#"Reordered Columns", {"fk_LayerId"}, {{"Rows", each _, type table [fk_LayerId=nullable number, order=nullable number, Count=nullable number, value=nullable number]}}),
    Indexed = Table.TransformColumns(#"Grouped Rows", {{"Rows", each Table.AddIndexColumn(_,"GroupIndex", 1, 1)}}),
    #"Expanded Rows" = Table.ExpandTableColumn(Indexed, "Rows", {"Count", "value", "GroupIndex"}, {"Count", "value", "GroupIndex"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Expanded Rows",{{"GroupIndex", Int64.Type}, {"Count", Int64.Type}, {"value", type number}}),
    #"Renamed Columns2" = Table.RenameColumns(#"Changed Type2",{{"GroupIndex", "order"}, {"Count", "count"}})
in
    #"Renamed Columns2"

 

as I needed the order (Index) to restart for each Id

 

 

View solution in original post

3 REPLIES 3
jgeddes
Super User
Super User

if @BA_Pete 's solution does not work for you I went a bit of a different direction.

I expanded upon your data to start with...

jgeddes_0-1670433228259.png

Did the following...

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSAWMjIDbQM1WK1YmG8yFyMBFjKDYAi4DkTaDYCC5iCtWFUGMGNwskAtJvDrNNKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Order = _t, Count = _t, Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Order", Int64.Type}, {"Count", Int64.Type}, {"Value", type number}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Numbers(1,[Count],0)),
#"ExpandTableColumns" = Table.ExpandListColumn(#"Added Custom", "Custom"),
#"Removed Columns" = Table.RemoveColumns(ExpandTableColumns,{"Order", "Count"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "Count"}}),
#"Added Index" = Table.AddIndexColumn(#"Renamed Columns", "Order", 1, 1, Int64.Type),
#"Reordered Columns" = Table.ReorderColumns(#"Added Index",{"ID", "Order", "Count", "Value"})
in
#"Reordered Columns"

And ended up with... 

jgeddes_1-1670433322991.png

Cheers!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thank you for this!

I used a very similar method to get my solution:

....

#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Sorted Rows2", {"fk_LayerId", "order", "value"}, "Attribute", "Value.1"),
    #"Added Custom" = Table.AddColumn(#"Unpivoted Other Columns", "Custom", each Table.Repeat(Table.FromRecords({[Col1=1]}),[Value.1])),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Col1"}, {"Col1"}),
    #"Removed Columns1" = Table.RemoveColumns(#"Expanded Custom",{"Attribute", "Value.1"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns1",{{"Col1", "Count"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Count", Int64.Type}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Changed Type1",{"fk_LayerId", "order", "Count", "value"}),
    #"Grouped Rows" = Table.Group(#"Reordered Columns", {"fk_LayerId"}, {{"Rows", each _, type table [fk_LayerId=nullable number, order=nullable number, Count=nullable number, value=nullable number]}}),
    Indexed = Table.TransformColumns(#"Grouped Rows", {{"Rows", each Table.AddIndexColumn(_,"GroupIndex", 1, 1)}}),
    #"Expanded Rows" = Table.ExpandTableColumn(Indexed, "Rows", {"Count", "value", "GroupIndex"}, {"Count", "value", "GroupIndex"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Expanded Rows",{{"GroupIndex", Int64.Type}, {"Count", Int64.Type}, {"value", type number}}),
    #"Renamed Columns2" = Table.RenameColumns(#"Changed Type2",{{"GroupIndex", "order"}, {"Count", "count"}})
in
    #"Renamed Columns2"

 

as I needed the order (Index) to restart for each Id

 

 

BA_Pete
Super User
Super User

Hi @pfInigo ,

 

Need a bit more info around what these fields represent and how dynamic this needs to be.

The easiest way to duplicate the rows [Count] times would be to add a new column with this:

= {1..[Count]}

...then expand this column.

Re-incrementing the [Order] column could be done by subsequently adding an Index column, and re-stating the [Count] column would just be a new column with ' = 1 ' as the calculation, but these options aren't dynamic.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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