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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
gauravnarchal
Post Prodigy
Post Prodigy

Matching Columns in 2 Tables

I have two tables as shown below. I want to validate and match the values from Product and category column of table 1 with Product and category column of Table 2 else it should return “Incorrect Value”.

 

Table 1 is being updated by the staff manually in the excel whereas Table 2 is the database from where I want the information to be validated.

 

Instead of creating a lookup table, can this be done through measure? Pls suggest the best option.

 

Table 1

Ref IDProductCategory
2349898729WWY
2449898728WWY
2549898727WWO
2649898726WWO
2749898725KKY
2849898724KKY
2949898723KKY
3049898722KKY
3149898721KKW
3249898720WWE
3349898719WWE
3449898718TTR
3549898717TTR
3649898716TTR
3749898715TTR
3849898714PPM
3949898713PPM
4049898712PPN

 

Table 2

ProductCategory
WWY
WWO
KKY
TTR
PPM
PPN

 

How the result should be displayed

Ref IDProductCategoryResult
2349898729WWYValid
2449898728WWYValid
2549898727WWOValid
2649898726WWOValid
2749898725KKYValid
2849898724KKYValid
2949898723KKYValid
3049898722KKYValid
3149898721KKWIncorrect Value
3249898720WWEIncorrect Value
3349898719WWEIncorrect Value
3449898718TTRValid
3549898717TTRValid
3649898716TTRValid
3749898715TTRValid
3849898714PPMValid
3949898713PPMValid
4049898712PPNValid

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@gauravnarchal , Try the option

 

new Measure = if(isblank(countx(filter(Table1, Table1[product] = max(Table2[product]) && Table1[Category] = max(Table2[Category])),Table2[Category])) ,"Incorrect Value", "Valid")

 

new column = if(isblank(countx(filter(Table2, Table2[product] =Table1[product] && Table2[Category] =Table1[Category]),Table2[Category])) ,"Incorrect Value", "Valid")

View solution in original post

Sumanth_23
Memorable Member
Memorable Member

hi @gauravnarchal

 

I have created the required solution using check at the table level - see below for the steps to create the same 

Note: You can hide the Key column from report view if you do not want users to see the same. 

 

1. Create key column for Mapping table 

Key = 'Mapping table'[Product] & "-" & 'Mapping table'[Category]
 
Data Validation1.jpg
 
2. Create key column in Data table
Key = 'Data Entry Table'[Product] & "-" & 'Data Entry Table'[Category]
 
Data Validation2.jpg
3. Create relationship between the "Key" columns between both tables
 
4. Create check column in Data table 
Check = if ('Data Entry Table'[Key] = RELATED('Mapping table'[Key]) , "Valid", "Incorrect Value")
 
Data Validation3.jpg
 
5. Create a table visual with the required data
Data Validation4.jpg

 

 

Please mark the post as a solution if my comment helped with solving your issue. Thanks! 

 

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!

Proud to be a Super User!



View solution in original post

3 REPLIES 3
Sumanth_23
Memorable Member
Memorable Member

hi @gauravnarchal

 

I have created the required solution using check at the table level - see below for the steps to create the same 

Note: You can hide the Key column from report view if you do not want users to see the same. 

 

1. Create key column for Mapping table 

Key = 'Mapping table'[Product] & "-" & 'Mapping table'[Category]
 
Data Validation1.jpg
 
2. Create key column in Data table
Key = 'Data Entry Table'[Product] & "-" & 'Data Entry Table'[Category]
 
Data Validation2.jpg
3. Create relationship between the "Key" columns between both tables
 
4. Create check column in Data table 
Check = if ('Data Entry Table'[Key] = RELATED('Mapping table'[Key]) , "Valid", "Incorrect Value")
 
Data Validation3.jpg
 
5. Create a table visual with the required data
Data Validation4.jpg

 

 

Please mark the post as a solution if my comment helped with solving your issue. Thanks! 

 

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!

Proud to be a Super User!



amitchandak
Super User
Super User

@gauravnarchal , Try the option

 

new Measure = if(isblank(countx(filter(Table1, Table1[product] = max(Table2[product]) && Table1[Category] = max(Table2[Category])),Table2[Category])) ,"Incorrect Value", "Valid")

 

new column = if(isblank(countx(filter(Table2, Table2[product] =Table1[product] && Table2[Category] =Table1[Category]),Table2[Category])) ,"Incorrect Value", "Valid")

Thanks @amitchandak .

 

Also, can you please let me know how can i compare only the product columns from table 1 & table 2?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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