Help with Lookup formula

Would someone please help with the below formula as I canโ€™t see what is wrong with it and its not working. I have uploaded an image to show table formats.

IFS(
[Supplier]=โ€œADA Fastfix - ADA02โ€,Lookup([Product],โ€œProduct Listโ€,โ€œProductSโ€,โ€œADA Fastfixโ€,),
[Supplier]=โ€œBSS - BSS01โ€,Lookup([Product],โ€œProduct Listโ€,โ€œProductSโ€,โ€œBSSโ€),
[Supplier]=โ€œWolseley - WOL01โ€,Lookup([Product],โ€œProduct Listโ€,โ€œProductSโ€,โ€œWolseleyโ€)
)

0 8 328
8 REPLIES 8

@Martina
Try it like this:

SWITCH(
	[Supplier],
	"ADA Fastfix - ADA02", LOOKUP([_THISROW].[Product],"Product List","ProductS","ADA Fastfix"),
	"BSS - BSS01", LOOKUP([_THISROW].[Product],"Product List","ProductS","BSS"),
	LOOKUP([_THISROW].[Product],"Product List","ProductS","Wolseley")
)

Thank You, that seems to be working.

Hmm, Iโ€™m curiousโ€ฆ why the usage of [_THISROW] in the first two LOOKUPs but not the third?

@WillowMobileSystems
Itโ€™s totally my badโ€ฆThanks for your valuable attentionโ€ฆFixed my post as well

It wasnโ€™t meant as a critique at all! I have just been trying to truly understand when [_THISROW] is required and when its not.

I use the rule of thumb โ€œwhen there is ambiguityโ€ such as the same column names between two data tables. But there seems to be outliers to this rule of thumb.

For instance, in this case there doesnโ€™t seem to be any ambiguity so I donโ€™t get why [_THISROW] is needed.

In other instances, when its not needed, the usage of it create problems - even though it seems it shouldnโ€™t matter.

It leaves me a confused little man!!

I believe the most competent person who can explain this is @Aleksi

The [_THISROW] is needed when you need to say for the SELECT expression to read the column not from the same table you specified in the SELECT. The ANY(SELECT(โ€ฆ)) experssion is typedโ€ฆ

ANY(SELECT(Product List[ADA Fastfix],[ProductS]=[_THISROW].[Product])), which is equal toโ€ฆ
LOOKUP([_THISROW].[Product],โ€œProduct Listโ€,โ€œProductSโ€,โ€œADA Fastfixโ€)

If you type the SELECT expression like SELECT(Product List[ADA Fastfix],[ProductS]=[Product]), it probably wonโ€™t work if you donโ€™t have the โ€œProductโ€ column at all in your โ€œProduct listโ€ table. If you type it likeโ€ฆ SELECT(Product List[ADA Fastfix],[ProductS]=[ProductS]), the contidion is always TRUE and you will have all values from that table.

Soโ€ฆ the SELECT expression is not able to know from which table it should read the value, if you donโ€™t specify it with the [_THISROW]. Think it like [_FROM_THIS_RECORD] and it reads the value where you have that formula).

Thanks everyone

Top Labels in this Space