Forum Discussion

jsanchezm's avatar
jsanchezm
Frequent Visitor
3 years ago
Solved

Get values from other table with conditional comparing values of two tables

Hi,

I've got an issue in Power Query and I can't figure out how to solve it:

 

In my scenario there are 2 tables: 

  • Mestres: that holds a few (about 40) records with specifically 3 columns that we need to use in our query: Tipus, CodiTip and Viatges.

 

  • Vendes: a huge table that needs to add a column as a result from querying "Mestres". In "Vendes" we also have the "Tipus" and "CodiTip" columns, so we can compare both tables column's values:
    • if Vendes[Tipus] is T, then add a 0 in our new column in Vendes,
    • Otherwise, search in "Mestres" the value the column Viatges comparing the Tipus and CodiTip columns and if they match retrieve the "Viatges" value to put it in our new column in "Vendes".

Hope I've explained enough my problem. 

Thanks in advance for your time.

  • Hi jsanchezm 

     

    You can use the Merge queries feature. Merge queries overview - Power Query | Microsoft Learn

    You can select multiple columns to perform the join by selecting Ctrl as you select the columns. When you do so, the order in which the columns were selected is displayed in small numbers next to the column headings, starting with 1.

    After merging, expand only Viatges column to "Vendes" table. 

    Finally add a conditional column like below. 

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.

2 Replies