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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
EllieKS
Frequent Visitor

Check Column Values in a Table for a List of Characters in Another Table

Hi, I am trying to evaluate with calculated columns whether the values in a column with mixed data types contain any character listed in another table.

 

I have two tables, Table A contains a list of all characters I need to search for in the Data Column of Table B which has mixed data types. I have added two columns to Table B showing the desired result. Any help would be much appreciated.!

 

Table A Table B  
Characters Data ColumnDesired Result - True/FalseDesired Result - Character
" Name@email.comFALSE 
# 2016-05-27T11:00:00TRUE:
% 8964df00-dba8-4834-8964-75323a35df63FALSE 
& 4000FALSE 
* 500.22FALSE 
: n/aTRUE/
< *Check ReferenceTRUE*
> >200TRUE>
? Text 123FALSE 
\ TextFALSE 
{ 123FALSE 
} ABC & 123TRUE&
|    
~    
/    
2 ACCEPTED SOLUTIONS
ebeery
Memorable Member
Memorable Member

@EllieKS there are probably several possible solutions to this, but one way I've used before is using Power Query.

Here are a couple blog posts from which I adapted the code.

Searching for text strings in power query 
Create a list of matching words when searching text in power query 

ebeery_0-1640971130283.png

After converting TableA in to a list (CharacterList), the code for Table B looked like this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("PYvBCsIwEER/peQopm52kzR6Unv3IL3VHmKzQdFUEAU/XxursLAzjzdtK3Y+8ZqTP1/L/pZEN28FgrISjMSqUWoF8LnM3dLqEAFkOHontSMtRyQrQ0ieTIiWsqhhWhiAEjHHYeHzn9Un7i/FniPfeeg5w8MTgBinVcOvR6GQ/iWHH9hs62L00X6d7g0=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Data Column" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Data Column", type text}}),
    #"Added True/False" = Table.AddColumn(#"Changed Type", "Found?",
        (FindStrings) =>
        List.AnyTrue(List.Transform(CharacterList, each Text.Contains((FindStrings[Data Column]), _ )))),
    #"Added Found Character" = Table.AddColumn(#"Added True/False", "Found Character",
    each List.Accumulate
        (
            CharacterList,
            "",
            (state, current) =>
                if Text.Contains([Data Column], current, Comparer.OrdinalIgnoreCase)
                then state & " " & current
                else state

        ))
in
    #"Added Found Character"

 

See .pbix file linked below:

https://drive.google.com/file/d/1JPteKLcVGLz40eOTZkZpIR-Hnc2SyPBk/view?usp=sharing 

View solution in original post

mahoneypat
Microsoft Employee
Microsoft Employee

The solution by @ebeery is a good one. FYI that you can mark it as a solution even if you can't use an M solution. Here is a DAX measure that works too. You can switch between the return lines to get the two different values (T/F or which character(s) is found).

 

DAX Found =
VAR chars =
    DISTINCT ( TableA[Characters] )
VAR datavalue =
    MIN ( TableB[Data Column] )
VAR result =
    FILTER ( charsFIND ( TableA[Characters], datavalue10 ) ) 

// return countrows(result) > 0
RETURN
    CONCATENATEX ( result, TableA[Characters], "," )

 

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
mahoneypat
Microsoft Employee
Microsoft Employee

The solution by @ebeery is a good one. FYI that you can mark it as a solution even if you can't use an M solution. Here is a DAX measure that works too. You can switch between the return lines to get the two different values (T/F or which character(s) is found).

 

DAX Found =
VAR chars =
    DISTINCT ( TableA[Characters] )
VAR datavalue =
    MIN ( TableB[Data Column] )
VAR result =
    FILTER ( charsFIND ( TableA[Characters], datavalue10 ) ) 

// return countrows(result) > 0
RETURN
    CONCATENATEX ( result, TableA[Characters], "," )

 

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


That's perfect, thank you!

ebeery
Memorable Member
Memorable Member

@EllieKS there are probably several possible solutions to this, but one way I've used before is using Power Query.

Here are a couple blog posts from which I adapted the code.

Searching for text strings in power query 
Create a list of matching words when searching text in power query 

ebeery_0-1640971130283.png

After converting TableA in to a list (CharacterList), the code for Table B looked like this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("PYvBCsIwEER/peQopm52kzR6Unv3IL3VHmKzQdFUEAU/XxursLAzjzdtK3Y+8ZqTP1/L/pZEN28FgrISjMSqUWoF8LnM3dLqEAFkOHontSMtRyQrQ0ieTIiWsqhhWhiAEjHHYeHzn9Un7i/FniPfeeg5w8MTgBinVcOvR6GQ/iWHH9hs62L00X6d7g0=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Data Column" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Data Column", type text}}),
    #"Added True/False" = Table.AddColumn(#"Changed Type", "Found?",
        (FindStrings) =>
        List.AnyTrue(List.Transform(CharacterList, each Text.Contains((FindStrings[Data Column]), _ )))),
    #"Added Found Character" = Table.AddColumn(#"Added True/False", "Found Character",
    each List.Accumulate
        (
            CharacterList,
            "",
            (state, current) =>
                if Text.Contains([Data Column], current, Comparer.OrdinalIgnoreCase)
                then state & " " & current
                else state

        ))
in
    #"Added Found Character"

 

See .pbix file linked below:

https://drive.google.com/file/d/1JPteKLcVGLz40eOTZkZpIR-Hnc2SyPBk/view?usp=sharing 

Hi @ebeery  Thank you very much for the solution, however, Table B is a virtual table with values that change constantly, hence looking for a DAX solution ideally. I am not sure how I can use your solution in this case?

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

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.