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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
databot_kd
Helper III
Helper III

Power Query: Filter/Split values in rows from one column into multiple columns from a dynamic row

Hi community, 

 

Please can you assist we have a  list of organisation numbers in one column in a .txt file. 

This list contains all successful and unsuccesful organisation, example below:

 

Org Num
Successful 
123456
789456
98697
 
Not Successful
7896563
56986358
59789

 

My requirement is to split the one column into two columns, Successful |  Not successful 

 

Successful Not Successful
1234567896563
78945656986358
9869759789

 

Or just return only the Successful list if thats easier.

 

Thanks in advance

1 ACCEPTED SOLUTION
dufoq3
Community Champion
Community Champion

Hi @databot_kd, check this:

 

Output

dufoq3_0-1723796082097.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi5NTk4tLk4rzVFQitWJVjI0MjYxNQMzzS0sYUxLCzNLczALosovv0QBoROm2szUzBjMNjUDajA2tYBwLIFSSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Org Num" = _t]),
    Transformed = Table.FromColumns(List.Combine(List.Transform(Table.SplitAt(Source, List.PositionOf(Source[Org Num], "Not Successful")), Table.ToColumns))),
    PromotedHeaders = Table.PromoteHeaders(Transformed, [PromoteAllScalars=true]),
    FilteredRows = Table.SelectRows(PromotedHeaders, each ([Not Successful] <> null))
in
    FilteredRows

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

4 REPLIES 4
Omid_Motamedise
Super User
Super User

Use this formula

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
S1 = Source[Org Num],
Custom1 = Table.PromoteHeaders(Table.FromRows(List.Zip(List.Split(S1,List.PositionOf(S1,"Not Successful")))))
in
Custom1


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

Add Custom Column:

  • Right-click on "Column1" and select "Add Column" -> "Custom Column."
  • Name this new column "Status."
  • In the formula bar, enter this formula: if Text.Contains([Column1], "Successful") then "Successful"
    else if Text.Contains([Column1], "Not Successful") then "Not Successful"
    else null 

 

  • Add another custom column named "Org Num."
  • In the formula bar, enter: Text.Combine(List.Select(Text.Split([Column1], " "), each Text.Length(_) > 0 and Text.IsNumber(_)), " ")

 

  • Filter out rows where the "Status" column is null.
  • Right-click on the "Status" column and select "Pivot Column."
  • In the Pivot Column window:
    • Values Column: "Org Num"
    • Aggregation Function: "Don't Aggregate"
dufoq3
Community Champion
Community Champion

Hi @databot_kd, check this:

 

Output

dufoq3_0-1723796082097.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi5NTk4tLk4rzVFQitWJVjI0MjYxNQMzzS0sYUxLCzNLczALosovv0QBoROm2szUzBjMNjUDajA2tYBwLIFSSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Org Num" = _t]),
    Transformed = Table.FromColumns(List.Combine(List.Transform(Table.SplitAt(Source, List.PositionOf(Source[Org Num], "Not Successful")), Table.ToColumns))),
    PromotedHeaders = Table.PromoteHeaders(Transformed, [PromoteAllScalars=true]),
    FilteredRows = Table.SelectRows(PromotedHeaders, each ([Not Successful] <> null))
in
    FilteredRows

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Vidushi_Mangal
Regular Visitor

Add Custom Column:

  • Right-click on "Column1" and select "Add Column" -> "Custom Column."
  • Name this new column "Status."
  • In the formula bar, enter this formula: if Text.Contains([Column1], "Successful") then "Successful"
    else if Text.Contains([Column1], "Not Successful") then "Not Successful"
    else null 

 

  • Add another custom column named "Org Num."
  • In the formula bar, enter: Text.Combine(List.Select(Text.Split([Column1], " "), each Text.Length(_) > 0 and Text.IsNumber(_)), " ")

 

  • Filter out rows where the "Status" column is null.
  • Right-click on the "Status" column and select "Pivot Column."
  • In the Pivot Column window:
    • Values Column: "Org Num"
    • Aggregation Function: "Don't Aggregate"

 

Give a thumsup if solution is up to mark

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.