Forum Discussion

giuliapiazza94's avatar
4 years ago
Solved

Merge query with dax

Hi, 

I have two tables like 

1  

2

 

I'd like to have the values "Farm" in the first table using DAX.

How can I to do?

 

Thank you all 🙂

 

  • Hi giuliapiazza94 

     

    try this to add a new column in table 1:

    Farm = LOOKUPVALUE('Table 2'[Farm],'Table 2'[customer],'Table 1'[Customer])
     
     
    output:
     

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudos!!
    LinkedIn: 
    www.linkedin.com/in/vahid-dm/


     

6 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    giuliapiazza94 In your first query, add a Merge Query step in Power Query Editor to merge the second table on the customer columns.

     

    • giuliapiazza94's avatar
      giuliapiazza94
      Icon for Helper IV rankHelper IV

      I can't use Power Query because I haven't direct access to customer's database.

      I need to do this using only DAX

  • smpa01's avatar
    smpa01
    Icon for Community Champion rankCommunity Champion

    giuliapiazza94  you can create relationship between t1 and t2 through Customer column and then you can create a calculated column in t1 like following

    Farm from t2 = RELATED(t2[Farm])
    • giuliapiazza94's avatar
      giuliapiazza94
      Icon for Helper IV rankHelper IV

      I've tried but i've this error 

      but there is a relationship 1:m between two tables

  • Hi giuliapiazza94 

     

    try this to add a new column in table 1:

    Farm = LOOKUPVALUE('Table 2'[Farm],'Table 2'[customer],'Table 1'[Customer])
     
     
    output:
     

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudos!!
    LinkedIn: 
    www.linkedin.com/in/vahid-dm/


     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi giuliapiazza94 ,

     

    Does the replies above solve your problem? If it has been solved, please mark the correct reply as the standard answer to help the other members find it more quickly.Thanks in advance for your kind cooperation!

     

    Hope it helps,


    Community Support Team _ Caitlyn

    If this post helps then please consider Accept it as the solution to help the other members find it more quickly.