Forum Discussion

gauravnarchal's avatar
gauravnarchal
Post Prodigy
5 years ago
Solved

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

 

  • 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")

  • Anonymous's avatar
    Anonymous
    5 years ago

    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]
     
     
    2. Create key column in Data table
    Key = 'Data Entry Table'[Product] & "-" & 'Data Entry Table'[Category]
     
    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")
     
     
    5. Create a table visual with the required data

     

     

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

     

     

3 Replies

  • 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")

    • gauravnarchal's avatar
      gauravnarchal
      Post Prodigy

      Thanks amitchandak .

       

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

  • Anonymous's avatar
    Anonymous
    Not applicable

    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]
     
     
    2. Create key column in Data table
    Key = 'Data Entry Table'[Product] & "-" & 'Data Entry Table'[Category]
     
    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")
     
     
    5. Create a table visual with the required data

     

     

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