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
vijaykaali811
Helper I
Helper I

power query matching pattern

i have table1 with column title column another table2 with column pattern and category

table1.title 

"job xx run on"

"password  for id xxx  expired"

table2

pattern category 

job*run    Jobrun    

password*expired  passwordexpiry 

with this now i want to get category in table1  with values table1.title matching table2.pattern , get table2.category 

I did this in excel with just xlookup and match. 

But how to do that in Powerquery power bi 

1 ACCEPTED SOLUTION
Shravan133
Super User
Super User

Add Custom Column to Match Patterns

In Table1, add a custom column that looks through each Pattern in Table2, checks if it matches using a basic wildcard logic (we'll treat * as "any characters"), and returns the corresponding Category.

Go to Add Column > Custom Column in Table1 and paste:

let

    currentTitle = [Title],

    matchedCategory =

        List.First(

            List.Transform(

                Table.SelectRows(Table2, each

                    Text.Contains(currentTitle, Text.BeforeDelimiter([Pattern], "*"))

                    and Text.Contains(currentTitle, Text.AfterDelimiter([Pattern], "*"))

                )[Category],

                each _

            ),

            null

        )

in

    matchedCategory

This assumes your Pattern always has a single * (wildcard) in the middle.

What this does:

  • For each row in Table1, it:
    • Loops through all Patterns in Table2
    • Breaks each pattern at the * into two parts
    • Checks that the Title contains both parts
    • Returns the first matching Category

Example Result

Title

Category

job xx run on

Jobrun

password for id xxx expired

passwordexpiry

 

View solution in original post

3 REPLIES 3
vijaykaali811
Helper I
Helper I

it worked .   but with multiple wildcard in pattern . it will be difficult as number of wildcard is not predictable 

 

vijaykaali811
Helper I
Helper I

Lightening speed answer . thanks 

Shravan133
Super User
Super User

Add Custom Column to Match Patterns

In Table1, add a custom column that looks through each Pattern in Table2, checks if it matches using a basic wildcard logic (we'll treat * as "any characters"), and returns the corresponding Category.

Go to Add Column > Custom Column in Table1 and paste:

let

    currentTitle = [Title],

    matchedCategory =

        List.First(

            List.Transform(

                Table.SelectRows(Table2, each

                    Text.Contains(currentTitle, Text.BeforeDelimiter([Pattern], "*"))

                    and Text.Contains(currentTitle, Text.AfterDelimiter([Pattern], "*"))

                )[Category],

                each _

            ),

            null

        )

in

    matchedCategory

This assumes your Pattern always has a single * (wildcard) in the middle.

What this does:

  • For each row in Table1, it:
    • Loops through all Patterns in Table2
    • Breaks each pattern at the * into two parts
    • Checks that the Title contains both parts
    • Returns the first matching Category

Example Result

Title

Category

job xx run on

Jobrun

password for id xxx expired

passwordexpiry

 

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.