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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
AleksandrMe
Resolver I
Resolver I

PIVOT/UNPIVOT

Good day, 

 

I have problem to create nice columns of data I need. Due to complicated excel format of source files, I have following sample file structure: 

 

AleksandrMe_0-1602059425001.png

 

What I'm looking for is the getting rid of nul/numbers and repetitions fnaly two rows of thext one oposite to other to make connetions later. 

 

THnaks

Aleks 

 

1 ACCEPTED SOLUTION

Hello @AleksandrMe 

 

check out this code. Uses Table.Group to group data by question number. The function applied combines text from column2 and column1

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrdQ0lEKLE0tLsnMz1OK1YlWKkmtKFFIBIqCeSEgXhIKLxnGM7dE0qsA5MGVOKJowMaLBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","",null,Replacer.ReplaceValue,{"Column1", "Column2"}),
    GroupNumbers = Table.Group
    (
        #"Replaced Value",
        {"Column1"},
        {
            {
                "AllRows",
                each Text.Combine(_[Column2], " ") & " - " & Text.Combine(List.Skip(_[Column1],1)," ")
            }
        },
        GroupKind.Local,
        (group,current)=> try if Value.Is(Number.From(current[Column1]),type number) then 1 else 0 otherwise 0
    )
in
    GroupNumbers

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

4 REPLIES 4
Jimmy801
Community Champion
Community Champion

Hello @AleksandrMe 

 

what is the logic to connect the rows of text? What is your final output looking like?

 

BR

 

Jimmy

Hi Jimmi, 

 

There is one report using text data from second column. Now I need to connect this text data with "suggested actions" in the first column. This needs to be separate query and I will use connections. 

 

Numbers and emty rows need to go away as it came with the EXCEL - Cannot get rid of them without loosing text in the first column. 

Hello @AleksandrMe 

 

check out this code. Uses Table.Group to group data by question number. The function applied combines text from column2 and column1

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrdQ0lEKLE0tLsnMz1OK1YlWKkmtKFFIBIqCeSEgXhIKLxnGM7dE0qsA5MGVOKJowMaLBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","",null,Replacer.ReplaceValue,{"Column1", "Column2"}),
    GroupNumbers = Table.Group
    (
        #"Replaced Value",
        {"Column1"},
        {
            {
                "AllRows",
                each Text.Combine(_[Column2], " ") & " - " & Text.Combine(List.Skip(_[Column1],1)," ")
            }
        },
        GroupKind.Local,
        (group,current)=> try if Value.Is(Number.From(current[Column1]),type number) then 1 else 0 otherwise 0
    )
in
    GroupNumbers

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Fowmy
Super User
Super User

@AleksandrMe 

Can you share some sample data and the expected result to have a clear understanding of your question?
You can save your files in OneDrive, Google Drive, or any other cloud sharing platforms and share the link here.
____________________________________
How to paste sample data with your question?
How to get your questions answered quickly?

_____________________________________
Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube, LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.