简体   繁体   中英

Power Bi - Lookup for A Value in Different Table (Reference Table) and Return True

In Microsoft Power Bi

I have 850 products and a total of 15 vendors for these products.

I have two tables where the 1st table shows distinct list of products with only 8 vendors sorted from lowest to highest price (1 to 8):

表格1

and the second table shows the actual buying of every product with vendor name, quantity and price:

表 2

I need a column that checks if the vendor exists among the 8 choices for each product and return true. If not, it should return false.

Hope it's clear.

Thanks all :)

You can use this below Measure for your purpose-

true_false = 

var current_row_product = MIN(Table2[product])
var current_row_vendor = MIN(Table2[vendor])

var find_vendor =  
CALCULATE(
    MAX(Table1[product]),
    FILTER(
        ALL(Table1),
        Table1[product] = current_row_product
        && current_row_vendor IN 
        {
            Table1[1st],
            Table1[2nd],
            Table1[3rd],
            Table1[4th],
            Table1[5th],
            Table1[6th],
            Table1[7th],
            Table1[8th]
        }
    )
)


RETURN IF(find_vendor = BLANK(), "FALSE", "TRUE")

Here below is the output-

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM