Forum Discussion

AvPowerBI's avatar
AvPowerBI
Icon for Post Patron rankPost Patron
4 years ago
Solved

If Column from different table match then Yes Else No

Hi,

 

I have two tables Sales and Product. The Sales table is a transactional table, so it has columns like Order No, Order Line No, ProductKey, Value etc.. 

The Product table just has one column called ProductKey

The two tables are joined together by ProductKey

I want to add another column to the Sales table by doing a calculated column or measure (whichever one is best) which I want to call "Special Product" where if the ProductKey from the Sales table exists in the Product table then label this as Yes else if it does not exists then No

 

Thanks

  • AvPowerBI Maybe:

    Column =
      VAR __ProductKey = [ProductKey])
      VAR __Match = COUNTROWS(FILTER('Product',[ProductKey] = __ProductKey))
    RETURN
      IF(ISBLANK(__Match),"No","Yes")

1 Reply

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    AvPowerBI Maybe:

    Column =
      VAR __ProductKey = [ProductKey])
      VAR __Match = COUNTROWS(FILTER('Product',[ProductKey] = __ProductKey))
    RETURN
      IF(ISBLANK(__Match),"No","Yes")