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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Extract table from column

Hi guys...

I'm trying to extract all data from this column keeping all data in one column only, separated by comma.

 

Capture2.PNG

 

Capture.PNG

1 ACCEPTED SOLUTION
edhans
Super User
Super User

Hi @Anonymous 

 

There isn't one function to do this in a quick step. This below will walk you through the logic of it. Put this M code in a blank query:

1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUUosTklTitWJVnJC5jgjc0DKKioq4KpgbGcYOxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Data = _t, Test = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Data", type text}, {"Test", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Data"}, {{"All Rows", each _, type table [Data=text, Test=text]}}),
    #"Added Just the Test Column as Table" = Table.AddColumn(#"Grouped Rows", "Test Column", each Table.SelectColumns([All Rows], "Test")),
    #"Added Transposed Table" = Table.AddColumn(#"Added Just the Test Column as Table", "Transposed Table", each Table.Transpose([Test Column])),
    #"Added Table as a List" = Table.AddColumn(#"Added Transposed Table", "Table as a List", each Table.ColumnNames([Transposed Table])),
    #"Added Concatenated Fields" = Table.AddColumn(#"Added Table as a List", "Concatenated Fields", each Table.CombineColumns([Transposed Table],[Table as a List], Combiner.CombineTextByDelimiter(","), "Test")),
    #"Expanded Custom.2" = Table.ExpandTableColumn(#"Added Concatenated Fields", "Concatenated Fields", {"Test"}, {"Test"})
in
    #"Expanded Custom.2"

 

Kind of the long way, but this is easier to read:

2020-04-13 18_20_41-Untitled - Power Query Editor.png

Start with step 1. The first few steps were just me slapping in some data to get a nested table with a single column really quickly.

  1. This is the single column like yours.
  2. Transposed this table
  3. Converted the table to a list
  4. Expanded the list and concantenated the fields together as I did
  5. Expanded the final column giving you the asdf,xxx field.

This should work with multiple rows, not just two.

 

If you need further help, please post back with sample data.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

2 REPLIES 2
edhans
Super User
Super User

Hi @Anonymous 

 

There isn't one function to do this in a quick step. This below will walk you through the logic of it. Put this M code in a blank query:

1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUUosTklTitWJVnJC5jgjc0DKKioq4KpgbGcYOxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Data = _t, Test = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Data", type text}, {"Test", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Data"}, {{"All Rows", each _, type table [Data=text, Test=text]}}),
    #"Added Just the Test Column as Table" = Table.AddColumn(#"Grouped Rows", "Test Column", each Table.SelectColumns([All Rows], "Test")),
    #"Added Transposed Table" = Table.AddColumn(#"Added Just the Test Column as Table", "Transposed Table", each Table.Transpose([Test Column])),
    #"Added Table as a List" = Table.AddColumn(#"Added Transposed Table", "Table as a List", each Table.ColumnNames([Transposed Table])),
    #"Added Concatenated Fields" = Table.AddColumn(#"Added Table as a List", "Concatenated Fields", each Table.CombineColumns([Transposed Table],[Table as a List], Combiner.CombineTextByDelimiter(","), "Test")),
    #"Expanded Custom.2" = Table.ExpandTableColumn(#"Added Concatenated Fields", "Concatenated Fields", {"Test"}, {"Test"})
in
    #"Expanded Custom.2"

 

Kind of the long way, but this is easier to read:

2020-04-13 18_20_41-Untitled - Power Query Editor.png

Start with step 1. The first few steps were just me slapping in some data to get a nested table with a single column really quickly.

  1. This is the single column like yours.
  2. Transposed this table
  3. Converted the table to a list
  4. Expanded the list and concantenated the fields together as I did
  5. Expanded the final column giving you the asdf,xxx field.

This should work with multiple rows, not just two.

 

If you need further help, please post back with sample data.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Greg_Deckler
Super User
Super User

@ImkeF @edhans

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors