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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
gemcityzach
Helper IV
Helper IV

Can PowerQuery Determine How Many Concatenations are in a field?

Hey there, I have a data set where a few of the fields contain concatenated values. The values get that way because form fields will allow the user to select multiple inputs. The field is pipe delimited. How could I go about (1) determining if any given record contains concatenated values in those fields, and (2) count how many possible concatenations are in each given field for a given record?

 

IDTitleConcat_1Concat_2concat_1_concat?concat_2_concat?Concat_1_countConcat_2_count
1aabc|def|pqrItem1|Item2|Item3|Item4YesYes34
2babcItem1NoNo11
3cabc|def|pqr|xyzItem2YesNo41

 

Edit: Figure out part 1. Using the following tells me if a PIPE/concatenated value is present

each if [field_name] = null then 0 else Text.Contains([field_name]), "|") then 1 else 0

1 ACCEPTED SOLUTION
AMeyersen
Resolver II
Resolver II

Hi @gemcityzach ,

 

are you looking for something like this?

#"Added Conditional Column" = Table.AddColumn(
    #"previous step", 
    "Concat_1_count", 
    each Text.Length(Text.Select([Concat1], "|")) + 1, 
    type number
  ), 
  #"Added Conditional Column1" = Table.AddColumn(
    #"Added Conditional Column", 
    "Concat_1_concat?", 
    each if [Concat_1_count] > 1 then "TRUE" else "FALSE", 
    type logical

 AMeyersen_0-1734603370182.png

 

View solution in original post

6 REPLIES 6
AMeyersen
Resolver II
Resolver II

Hi @gemcityzach ,

 

are you looking for something like this?

#"Added Conditional Column" = Table.AddColumn(
    #"previous step", 
    "Concat_1_count", 
    each Text.Length(Text.Select([Concat1], "|")) + 1, 
    type number
  ), 
  #"Added Conditional Column1" = Table.AddColumn(
    #"Added Conditional Column", 
    "Concat_1_concat?", 
    each if [Concat_1_count] > 1 then "TRUE" else "FALSE", 
    type logical

 AMeyersen_0-1734603370182.png

 

That's more or less what I ended up doing. For the detect pipes I used a text.contain and then to count pipes I did exactly what you suggest and added +1 to account for the starting index value that is almost always there.

djurecicK2
Super User
Super User

 

 

What do you mean by "How many possible concatenations are in each given field for a given record?" What is the expected result from your sample data?

The expected result is in the example. ID 1 shows the count of concatenated values in the different reference fields.

Not sure I understand the List.Max bit. The code you provided appears to give me the count of multiple pipes in the field.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.