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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Extract specific values from an column that contains a delimited list

I have a column that has a list of information delimited by ",". Example:

CodeA-45341,CodeB-35841,CodeC-87863,CodeA-45341,CodeB-35841,CodeC-87863

 

I want to extract all of the "CodeA"s. So from that example, the output would be:

CodeA-45341,CodeA-45341

 

A Screenshot of more samples:

Annotation.png

 

I can handle if there are only two occurrences by combining:

Text.Middle([Input],Text.PositionOf([Input],"CodeA", Occurrence.First), 11)

Text.Middle([Input],Text.PositionOf([Input],"CodeA", Occurrence.Last), 11)

 

Using Occurrence.All provides a list of numbers that the function doesn't handle. I assume there is a way to handle it with that, but it's just not coming to me.

Some items to note:

"CodeA" information is not static like it is in my example. It could be followed by any series of numbers and letters.

"CodeA" may not exist, and should result in a null cell.

The "Input" column can have any number of items to parse though

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Try this in a new custom column:

 

List.Select(
    Text.Split([Input], ","),
    each Text.Contains(_ , "CodeA")
)

 

From here you can either extract to new rows or extract values, whatever you need.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Try this in a new custom column:

 

List.Select(
    Text.Split([Input], ","),
    each Text.Contains(_ , "CodeA")
)

 

From here you can either extract to new rows or extract values, whatever you need.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Vijay_A_Verma
Super User
Super User

In a custom column, use following

= if Text.Contains([Input],"CodeA") then Text.Combine(List.Select(Text.Split([Input],","),(x)=>Text.Start(x,5)="CodeA"),",") else null

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs5PSXXUNTE1NjHUAbGddI1NLaBsZ10LcwszYx0i1CjF6kDMAsqZACGc76hraGRsYmpmbmFgYGikFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Input = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each if Text.Contains([Input],"CodeA") then Text.Combine(List.Select(Text.Split([Input],","),(x)=>Text.Start(x,5)="CodeA"),",") else null)
in
    #"Added Custom"

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors