Forum Discussion

newpbiuser01's avatar
newpbiuser01
Helper V
2 years ago
Solved

Flag Matching Rows in Different Tables

Hello,

 

I am trying to flag rows with matching values in two different tables. As an example, I have two tables, Table1 with a list of items, and some reference data tied to the items. Table2 is a smaller table with only 1 column and just has a list of items. The goal is to go through Table1 and flag any items found in Table2. I can't do this in a calculated column because I'll be using the userprincipalname() function to filter items by Shopper in my table.  Is it possible to do it in a measure? Since these tables don't have the same number of columns, I can't use the intersect function so I'm at a loss as to how to implement it. 

 

Table1: 

CategoryItemPriceQuantityShopper
FruitApple21A
FruitOrange31B
FruitPear51C
VegetableSpinach101A
VegetableTomato62V
Office SuppliesPen51C
Office SuppliesMarkers21E
Household SuppliesPape Towel201D
Household SuppliesDetergent31G

 

Table2: 

Item
Apple
Orange
Pear
Spinach

 

Desired Result: 

CategoryTypePriceQuantityResult
FruitApple21Yes
FruitOrange31Yes
FruitPear51 
VegetableSpinach101Yes
VegetableTomato62 
Office SuppliesPen51 
Office SuppliesMarkers21 
Household SuppliesPape Towel201 
Household SuppliesDetergent31 

 

Would anyone know how I could implement this? I'd really appreciate any help. 

 

Thank you. 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi newpbiuser01 ,

     

    You can create a measure.

    Result = IF(MAX('Table1'[Item]) in VALUES('Table2'[Item]), "Yes", BLANK())

     

    Best Regards,

    Neeko Tang

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

4 Replies

  • newpbiuser01 , You can add a new column in Table1

     

    New col =

    Var _cnt = countx(filter(Table2, Table1[Item] = Table2[Item]), Table2[Item])

    return

    if(isblank(_cnt), blank(), "Yes")

    • newpbiuser01's avatar
      newpbiuser01
      Helper V

      Hi amitchandak,

       

      Would you know if/how I could implement this as a measure? The reason I ask is, the goal is to make this "filterable" by the Shopper - which in my dataset is derived from the user() function. Unfortunately, I can't use that function in a calculated column. 

       

      Thank you!

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi newpbiuser01 ,

         

        You can create a measure.

        Result = IF(MAX('Table1'[Item]) in VALUES('Table2'[Item]), "Yes", BLANK())

         

        Best Regards,

        Neeko Tang

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