Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

DAX or Query: Compare two columns in different Tables

 

I have 2 tables and want to compare two columns (one from each) in query editor or dax. I just need a yes they (the text values) match or no (text values) don't match in a new column. Secondly I need a count of all the orders that do not match to table 2.

 Table 1 (Primary Table)

Order NoOrder Status
1234Resolved
1235Pending
1236Open
1237Resolved
1238Resolved
1239Pending

 

Table 2

Order NoOrder Status
1234Open
1235Resolved
1236

Pending

1237Resolved
1238Resolved
1239Open

 

 

I want a new column to be created (in either table) that shows when the Order status values in rows from each table match, as below:-

Order NoOrder StatusColumn 3
1234ResolvedNo Match
1235PendingNo Match
1236OpenMatch
1237ResolvedMatch
1238ResolvedMatch
1239PendingNo Match

 

Do i need to do this as a merge query or dax ?

 

Thanks

22 Replies

    • tulasi_pbi1988's avatar
      tulasi_pbi1988
      Helper I

      Hi Anonymous 

       

      If the relationship is Many to Many means?

      I have the same scenario to do, but I have Many to Many relationship.

      Do you have anything like this, please?

       

      Thank You

      • aj1973's avatar
        aj1973
        Community Champion

        Hi tulasi_pbi1988 

        What do you mean by like this????

        Please open a new thread and send me examples where I can look into your issue. Every model is unique and different.

        Thanks

    • Rookzie's avatar
      Rookzie
      New Member

      Hello, 

      i tired to enter this in as a new coulum but all i got back was "match" when i know some dont match. 

       

       

      any reason why this would happen? 

      • aj1973's avatar
        aj1973
        Community Champion

        Hi Rookzie 

        I don't understand what are you talking about !!!

        Can you open a new thread with more details of your issue and share it with me please?

  • Anonymous's avatar
    Anonymous
    Not applicable

    aj1973 Thank you so much this worked! I need to do a count of the total orders that have mismatched in the 3rd table how do I do this?

    • aj1973's avatar
      aj1973
      Community Champion

      I just updated the file for you

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi aj1973 unfortunatelty this didn't work 😞 

         

        The count is just giving me the count of all the rows in the 1st table not the new table created. 

         

        Also I have a change in requirement I need the 3rd table to show the order no, order status from both table 1 and 2, and  new column to be created that shows when the Order status values in rows from each table match, as below:-

        Order NoOrder Status (T1)

        Order Status

        (T2)

        Column 3
        1234OpenResolvedNo Match
        1235ResolvedPendingNo Match
        1236

        Pending

        OpenMatch
        1237ResolvedResolvedMatch
        1238ResolvedResolvedMatch
        1239OpenPendingNo Match

         

        I am getting duplicate rows when I take both table columns however can see the match/no match values. whereas if I do your example way it shows me all values as no match