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
OrionTL
New Member

DAX help with pattern matching between two non-related Tables

Hi,

 

I'm still new to Power BI, so any help is appreciated.

 

I have two tables, one with all raw data for who worked on what product like so (TableA):

Product Person Who Worked on it
ABC-ABBA Bob
DEF-ABBA Steve

 

I have a second table that dictates which of the products are harder to work on (TableB):

Hard Strenous Product
DEF

 

Is there a way to pattern match products from TableA with known hard streneous products from TableB and create a new column for it on TableA? I'm hoping for an "IF" statement where, if it's a hard product, return "HardProduct" and if it's not, then return "NotAHardProduct" within the cell values on the same rows like below:

 

Product Person Who Worked on it Product Type
ABC-ABBA Bob NotAHardProduct
DEF-ABBA Steve HardProduct

 

I know I can do this on M but within "M" I can't refer to the TableB from TableA when creating a custom column within TableA.

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @OrionTL 
Please follow sample file with the solution https://www.dropbox.com/t/wi6ldBAjf4fGEUkX

1.png

TableC = 
ADDCOLUMNS (
    TableA,
    "Product Type", 
        IF (
            ISEMPTY (
                FILTER (
                    TableB,
                    CONTAINSSTRING ( TableA[Product], TableB[Hard Strenous Product] )
                )
            ),
            "Not A Hard Product",
            "Hard Product"
        )
)

View solution in original post

5 REPLIES 5
tamerj1
Super User
Super User

Hi @OrionTL 
Please follow sample file with the solution https://www.dropbox.com/t/wi6ldBAjf4fGEUkX

1.png

TableC = 
ADDCOLUMNS (
    TableA,
    "Product Type", 
        IF (
            ISEMPTY (
                FILTER (
                    TableB,
                    CONTAINSSTRING ( TableA[Product], TableB[Hard Strenous Product] )
                )
            ),
            "Not A Hard Product",
            "Hard Product"
        )
)

Thank you @tamerj1 !

I was hoping to make it upon the already existing tableA but creating a new one is fine too.

 

I appreciate your help!

@OrionTL 
Ofcourse you can. Actually it is the same code of the column created inside ADDCOLUMNS 

1.png

ProductType = 
IF (
    ISEMPTY (
        FILTER (
            TableB,
            CONTAINSSTRING ( TableA[Product], TableB[Hard Strenous Product] )
        )
    ),
    "Not A Hard Product",
    "Hard Product"
)
tamerj1
Super User
Super User

Hi @OrionTL 

that would be much easier using dax calculated table or a measure in your power bi report. Would you consider that?

I have tried using a DAX calculatedtable like so

HType = 
VAR Matches =
CALCULATETABLE
(
    GENERATE('HardProducts',
    FILTER
    (
        Product_BuyOff,
        SEARCH
        (
            [Assemblies],
            [Part Number],
            1,
            0
        )
        >0)
    )
)
RETURN
    CONCATENATEX(
        Matches,
        "LH",",")


but I just get blank cells for the non-matching ones and "LH" for the matching ones. I can't figure out how to modify that code to make the blanks return another value when it's not matching.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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