Forum Discussion

Kagliostro's avatar
Kagliostro
Frequent Visitor
2 years ago
Solved

How to match comma separated cells values in two different columns and return missing values

Hi Everyone, new to Power BI and to DAX code and I need to perform a match between the content of two columns. Each column have a list of names that are separated by "," (comma) and I need the missi...
  • Greg_Deckler's avatar
    2 years ago

    Kagliostro Try this, PBIX is attached.

    Column = 
        VAR __PathA = SUBSTITUTE( [Column A], ",", "|" )
        VAR __PathB = SUBSTITUTE( [Column B], ",", "|" )
        VAR __CountA = LEN( [Column A] ) - LEN( SUBSTITUTE( [Column A], ",", "" ) ) + 1
        VAR __CountB = LEN( [Column B] ) - LEN( SUBSTITUTE( [Column B], ",", "" ) ) + 1
        VAR __TableA = 
            ADDCOLUMNS(
                GENERATESERIES( 1, __CountA ),
                "__Value", PATHITEM( __PathA, [Value] )
            )
        VAR __TableB = 
            ADDCOLUMNS(
                GENERATESERIES( 1, __CountB ),
                "__Value", PATHITEM( __PathB, [Value] )
            )
        VAR __Missing = EXCEPT( __TableA, __TableB )
        VAR __Result = CONCATENATEX( __Missing, [__Value], ", " )
    RETURN
        __Result