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

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

Reply
bukhari1979
Frequent Visitor

Searching Wild card String between two non related tables

Hi, I 've got two tables (not related to each other). Table1 has survey comments in text format and table2 has hot-words to categorize a survey into three main categories namely POSITIVE, NEGATIVE & GENERAL. I have written the code below but unfortunately the output is pretty weird as the output insert multiple results against every comment..probably it keeps looking into the comments and whenever it finds a match it insert the result in short ..it does the match but returns multiple values against a single record. Any help & correction will be highly appreciated Here is the code

 

CommentGrade = 
VAR Matches = 
CALCULATETABLE(
GENERATE(
Sheet1,FILTER( 
CSATAllData,
SEARCH(
[Perspective Name],[Comments],
1,
0
)>0)

)
)
RETURN 
CONCATENATEX(
Matches,
[PerspectiveGrade],",")

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @bukhari1979,

 

You can try to use below measures to get match key from other table.

 

Sample:

Matched = 
VAR _text =
    SELECTEDVALUE ( Table2[Text] )
RETURN
    CONCATENATEX (
        FILTER ( ALL ( KeyTable ), SEARCH ( [Key], _text, 1, -1 ) > 0 ),
        [Key],
        ","
    )


Matched Category = 
VAR _text =
    SELECTEDVALUE ( Table2[Text] )
RETURN
    CONCATENATEX (
        CALCULATETABLE (
            VALUES ( KeyTable[Category] ),
            FILTER ( ALL ( KeyTable ), SEARCH ( [Key], _text, 1, -1 ) > 0 )
        ),
        [Category],
        ","
    )

8.PNG

 

Regards,

Xiaoxin Sheng

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

HI @bukhari1979,

 

Please provide some sample data for test, I think it will be help for coding formula.

 

Regards,

Xiaoxin Sheng

Current SituationCurrent Situation

Hi @Anonymous hyg dear

 

Anonymous
Not applicable

Hi @bukhari1979,

 

You can try to use below measures to get match key from other table.

 

Sample:

Matched = 
VAR _text =
    SELECTEDVALUE ( Table2[Text] )
RETURN
    CONCATENATEX (
        FILTER ( ALL ( KeyTable ), SEARCH ( [Key], _text, 1, -1 ) > 0 ),
        [Key],
        ","
    )


Matched Category = 
VAR _text =
    SELECTEDVALUE ( Table2[Text] )
RETURN
    CONCATENATEX (
        CALCULATETABLE (
            VALUES ( KeyTable[Category] ),
            FILTER ( ALL ( KeyTable ), SEARCH ( [Key], _text, 1, -1 ) > 0 )
        ),
        [Category],
        ","
    )

8.PNG

 

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Hi, I am relatively new to Power BI and this is my first time posting.

 

I tried to adapt the above solution to simply produce a table showing the number of times a specific term from my mapping table appeared in my base data table. Unfortunately it didn't perform a wildcard match, just an exact match. How do I get it to do a wildcard match? 

 

Here's the code that I used (not sure if I'm posting correctly here): 

 

test1 =
VAR Matches =
CALCULATETABLE(generate('Job Function Map', Filter('Base Data',SEARCH('Job Function Map'[Job Function Codes], 'Base Data'[Job Function],1,0)>0)))
RETURN COUNTROWS('Base Data')
 
Here's a sample of the data for reference: 
Map 
CodeJob Function 2019
RESPNBLT1Corporate / General Management
RESPNBLT2Technical / Engineering
RESPNBLT3Administration
RESPNBLT4Business Development / Project Management
RESPNBLT5Consulting
RESPNBLT7Other (please specify)
etc. 

 

Data 
RowJob Function Codes
1RESPNBLT4, RESPNBLT8, RESPNBLT19, RESPNBLT16, RESPNBLT32
2RESPNBLT14
3RESPNBLT17
4RESPNBLT30, RESPNBLT14, RESPNBLT12, RESPNBLT28

 

Any tips or suggestions would be greatly appreciated.

 

Thanks!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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 Solution Authors
Top Kudoed Authors