Search code examples
powerpivotpowerbidax

Power BI-Compare 2 Text columns for equality using a measure


Data is similar to below:

enter image description here

OLD_ZEND comes from table1 and NEW_ZEND comes from table2. Looking to create a measure that will compare the strings of OLD_ZEND and NEW_ZEND and if they are the same output Y else output N.


Solution

  • I think what you need is a calculated column in one of your tables.

    Create an index column in each table by right clicking table1 and select Edit Query, the Query Editor will be opened, in the Add Column tab select Index Column - From 1 then press Close & Apply. Do the same for the table2.

    Then create a new calculated column in the table2, call it OLD_ZEND and use this DAX expression:

    OLD_ZEND =
        IF (
            [NEW_ZEND] = LOOKUPVALUE ( table1[OLD_ZEND], table1[Index], [Index] ),
            "Y",
            "N"
        )
    

    Now you have a new column in table2 with Y or N depending if OLD_ZEND and NEW_ZEND are equal.

    Let me know if this helps.