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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jerryr125
Helper III
Helper III

Power Query - create multiple rows

Hi - I would like to do the following - create a row for each value in a field.

 

Example:

 

IDFood Type
1Ice Cream; Cake; Cookies
2Apples; Bananas; Pears; Peaches
3Pizza


Output:

 

IDFood Type
1Ice Cream
1Cake
1Cookies
2Apples
2Bananas
2Peaches
2Pears
3Pizza


Therefore, the ";" indicates a new record (so to speak) - any thoughts ? Jerry

3 ACCEPTED SOLUTIONS
ronrsnfld
Super User
Super User

Source

ronrsnfld_0-1732311317004.png

 

 

You turn the string into a List, and then expand it:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfJMTlVwLkpNzLVWcE7MTgWS+fnZmanFSrE60UpGQAWOBQU5qcXWCk6JeUAIZASkJhZBqOQMqDpjoLqAzKqqRKXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Food Type" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Food Type", type text}}),
    #"Create List" = Table.TransformColumns(#"Changed Type",{"Food Type", each Text.Split(_,";"),type {text}}),
    #"Expanded Food Type" = Table.ExpandListColumn(#"Create List", "Food Type")
in
    #"Expanded Food Type"

 

Result

ronrsnfld_1-1732311349657.png

 

 

 

View solution in original post

AntrikshSharma
Super User
Super User

@jerryr125 Many ways to solve this, here is one using List.TransformMany

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfJMTlVwLkpNzLVWcE7MTgWS+fnZmanFSrE60UpGQAWOBQU5qcXWCk6JeUAIZASkJhZBqOQMqDpjoLqAzKqqRKXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Food Type" = _t]),
    ChangedType =
        Table.TransformColumnTypes ( Source, { { "ID", Int64.Type } } ), 
    Transform = 
        List.TransformMany (
            Table.ToRows ( ChangedType ), 
            ( z ) => Text.SplitAny ( z{1}, ";" ), 
            ( x, y ) => { x{0}, y }
        ), 
    ToTable = 
        Table.FromRows ( 
            Transform, 
            type table [ ID = Int64.Type, Food Type = text ] 
        )
in
    ToTable

AntrikshSharma_0-1732337135973.png

 

View solution in original post

Omid_Motamedise
Super User
Super User

Hi @jerryr125 , you can solve this problem by UI, just select the column Food Type, go to the homw tab, select Split Column by delimiter and make the setting presented in the below picture (it is important to select by row)

 

Omid_Motamedise_0-1732355213701.png

 


If my answer helped solve your issue, please consider marking it as the accepted solution.

View solution in original post

4 REPLIES 4
Omid_Motamedise
Super User
Super User

Hi @jerryr125 , you can solve this problem by UI, just select the column Food Type, go to the homw tab, select Split Column by delimiter and make the setting presented in the below picture (it is important to select by row)

 

Omid_Motamedise_0-1732355213701.png

 


If my answer helped solve your issue, please consider marking it as the accepted solution.
AntrikshSharma
Super User
Super User

@jerryr125 Many ways to solve this, here is one using List.TransformMany

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfJMTlVwLkpNzLVWcE7MTgWS+fnZmanFSrE60UpGQAWOBQU5qcXWCk6JeUAIZASkJhZBqOQMqDpjoLqAzKqqRKXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Food Type" = _t]),
    ChangedType =
        Table.TransformColumnTypes ( Source, { { "ID", Int64.Type } } ), 
    Transform = 
        List.TransformMany (
            Table.ToRows ( ChangedType ), 
            ( z ) => Text.SplitAny ( z{1}, ";" ), 
            ( x, y ) => { x{0}, y }
        ), 
    ToTable = 
        Table.FromRows ( 
            Transform, 
            type table [ ID = Int64.Type, Food Type = text ] 
        )
in
    ToTable

AntrikshSharma_0-1732337135973.png

 

jerryr125
Helper III
Helper III

Hi - I did a split then a unpivot and solved it - thanks so much - Jerry

ronrsnfld
Super User
Super User

Source

ronrsnfld_0-1732311317004.png

 

 

You turn the string into a List, and then expand it:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfJMTlVwLkpNzLVWcE7MTgWS+fnZmanFSrE60UpGQAWOBQU5qcXWCk6JeUAIZASkJhZBqOQMqDpjoLqAzKqqRKXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Food Type" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Food Type", type text}}),
    #"Create List" = Table.TransformColumns(#"Changed Type",{"Food Type", each Text.Split(_,";"),type {text}}),
    #"Expanded Food Type" = Table.ExpandListColumn(#"Create List", "Food Type")
in
    #"Expanded Food Type"

 

Result

ronrsnfld_1-1732311349657.png

 

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors