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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
databot_kd
Helper II
Helper II

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
Super User
Super User

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. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h
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
Super User
Super User

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 Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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