Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
nicolasvc
Helper III
Helper III

Match between columns of different tables

I have 2 tables, in one I have a value per product and the corresponding month with the year and store, and another table with the detailed cost for the month of each year, per product and store, but to this table I need to add the Value row, but with the value of that row when it matches the Store and Product, month and year (the first table only has one month ,in this case it is the first month, but it could be any, and I need that one) and 0 in case there is no match.

 

StoreProductYearMonthValue
1A20211500
1B202111000
......... ...

 

StoreProductYearMonthCostValue
1A202111000500
1A202125000
1B2021150001000
1B20212500

 

any comment with any help function or any comment, it is appreciated

1 ACCEPTED SOLUTION
TheoC
Super User
Super User

Hi @nicolasvc,

 

You can use Calculated Columns to add a unique code to each table:

 

col_UK = 'table'[STORE] &" " & 'table'[PRODUCT] &" "& 'table'[YEAR] &" " & 'table'[MONTH] )

 

and then perform a LOOKUP using a Calculated Column

 

col_Lookup = 

VAR _LookUKVal = LOOKUPVALUE( tbl2Facts[Value] , tbl2Facts[col_UK] , tbl1Store[col_UK] )

RETURN

IF ( _LookUKVal = 0 , 0 , _LookUKVal )

 

Your output will look like this (just adjust table names).  I just adjusted the below column to ensure it returns 0 if there is no value 🙂

 

TheoC_1-1634599085069.png

 

Hope this helps.

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

View solution in original post

4 REPLIES 4
TheoC
Super User
Super User

Hi @nicolasvc,

 

You can use Calculated Columns to add a unique code to each table:

 

col_UK = 'table'[STORE] &" " & 'table'[PRODUCT] &" "& 'table'[YEAR] &" " & 'table'[MONTH] )

and then perform a LOOKUP using a Calculated Column.

 

col_Lookup = 

VAR _LookUKVal = LOOKUPVALUE( tbl2Facts[Value] , tbl2Facts[col_UK] , tbl1Store[col_UK] )

RETURN

IF ( _LookUKVal = 0 , 0 , _LookUKVal )

 

Your output will look like this (just adjust table names).

 

TheoC_1-1634599991171.png

Hope this helps.

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

YukiK
Impactful Individual
Impactful Individual

In Power Query or your ETL tool, you can join table A on to table B on the key that is consisted of Store, Produst, Year, and Month (left join). Replace nulls with 0.

TheoC
Super User
Super User

Hi @nicolasvc,

 

You can use Calculated Columns to add a unique code to each table:

 

col_UK = 'table'[STORE] &" " & 'table'[PRODUCT] &" "& 'table'[YEAR] &" " & 'table'[MONTH] )

 

and then perform a LOOKUP using a Calculated Column

 

col_Lookup = 

VAR _LookUKVal = LOOKUPVALUE( tbl2Facts[Value] , tbl2Facts[col_UK] , tbl1Store[col_UK] )

RETURN

IF ( _LookUKVal = 0 , 0 , _LookUKVal )

 

Your output will look like this (just adjust table names).  I just adjusted the below column to ensure it returns 0 if there is no value 🙂

 

TheoC_1-1634599085069.png

 

Hope this helps.

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Thank you very much, what a great idea!

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors