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! Learn more

Reply
MinaPendar
Regular Visitor

add rows with same id in front of each row power bi

Hi everyone

I have one table like this

MinaPendar_1-1676035291989.png

I want to change it to this in Power BI

MinaPendar_0-1676035269107.png

How can I do that?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @MinaPendar ,

I created a sample pbix file(see the attachment), please check if that is what you want. You can achieve it in Power Query Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bY/LDsIgEEX/hXU3Npr+gjHRD7Bh0YSXxZRAik3/3jtDSFRcnMvjMDCMoziITlwfy4SBoYgxCtl9uRdQCrFtW3EnLO5TIrkAa/mEaqQD84wwxrDse77Wa9oD3nO5/Stz/pBHzC+BXwP7Trc796Nc/UV9j3o566cmuRIrF+8sh2HA6ha41USUSK3NtZ2MbGwgSgQh5Rs=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Name = _t, x = _t, y = _t, z = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Name", type text}, {"x", type text}, {"y", type text}, {"z", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"ID", "Name"}, 
                        {
                            {"x", each Text.Combine([x],",")},
                            {"Countx", each List.Count([x]), Int64.Type},
                            {"y", each Text.Combine([y],",")},
                            {"County", each List.Count([y]), Int64.Type},
                            {"z", each Text.Combine([z],",")},
                            {"Countz", each List.Count([z]), Int64.Type}
                        },
                        GroupKind.Global),
    getx = Table.RemoveColumns(
                    Table.SplitColumn( #"Grouped Rows", 
                                      "x", 
                                       Splitter.SplitTextByDelimiter(","), 
                                       List.Max(#"Grouped Rows"[Countx]), 
                                        "",
                                        ExtraValues.Ignore),
                    {"Countx"}
                    ),
    gety = Table.RemoveColumns(
                Table.SplitColumn( getx , 
                                  "y", 
                                    Splitter.SplitTextByDelimiter(","), 
                                    List.Max(#"Grouped Rows"[County]), 
                                    "",
                                    ExtraValues.Ignore),
                 {"County"}
  )
                ,
    getz = Table.RemoveColumns(
      Table.SplitColumn( gety , 
                          "z", 
                            Splitter.SplitTextByDelimiter(","), 
                            List.Max(#"Grouped Rows"[Countz]), 
                            "",
                            ExtraValues.Ignore),
                  {"Countz"}
      )
in
  getz

yingyinr_0-1676362229363.png

Best Regards

View solution in original post

2 REPLIES 2
MinaPendar
Regular Visitor

@Anonymous  Hi , Thank you, solve my problem.

Anonymous
Not applicable

Hi @MinaPendar ,

I created a sample pbix file(see the attachment), please check if that is what you want. You can achieve it in Power Query Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bY/LDsIgEEX/hXU3Npr+gjHRD7Bh0YSXxZRAik3/3jtDSFRcnMvjMDCMoziITlwfy4SBoYgxCtl9uRdQCrFtW3EnLO5TIrkAa/mEaqQD84wwxrDse77Wa9oD3nO5/Stz/pBHzC+BXwP7Trc796Nc/UV9j3o566cmuRIrF+8sh2HA6ha41USUSK3NtZ2MbGwgSgQh5Rs=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Name = _t, x = _t, y = _t, z = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Name", type text}, {"x", type text}, {"y", type text}, {"z", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"ID", "Name"}, 
                        {
                            {"x", each Text.Combine([x],",")},
                            {"Countx", each List.Count([x]), Int64.Type},
                            {"y", each Text.Combine([y],",")},
                            {"County", each List.Count([y]), Int64.Type},
                            {"z", each Text.Combine([z],",")},
                            {"Countz", each List.Count([z]), Int64.Type}
                        },
                        GroupKind.Global),
    getx = Table.RemoveColumns(
                    Table.SplitColumn( #"Grouped Rows", 
                                      "x", 
                                       Splitter.SplitTextByDelimiter(","), 
                                       List.Max(#"Grouped Rows"[Countx]), 
                                        "",
                                        ExtraValues.Ignore),
                    {"Countx"}
                    ),
    gety = Table.RemoveColumns(
                Table.SplitColumn( getx , 
                                  "y", 
                                    Splitter.SplitTextByDelimiter(","), 
                                    List.Max(#"Grouped Rows"[County]), 
                                    "",
                                    ExtraValues.Ignore),
                 {"County"}
  )
                ,
    getz = Table.RemoveColumns(
      Table.SplitColumn( gety , 
                          "z", 
                            Splitter.SplitTextByDelimiter(","), 
                            List.Max(#"Grouped Rows"[Countz]), 
                            "",
                            ExtraValues.Ignore),
                  {"Countz"}
      )
in
  getz

yingyinr_0-1676362229363.png

Best Regards

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 Solution Authors