Forum Discussion
CFrench11
Apr 13, 2022Copper Contributor
Formulas
I have an excel spreadsheet that has information in a table. The table shows prices for a flight based on destination and class (first or economy). I am trying to make it so that when the input is a ...
- Apr 13, 2022
I don't think it is a case of a 'correct' answer. There are many variations that will work and it also depends upon the version of Excel that you use. Using modern functions but stopping short of Lambda functions one might have
= XLOOKUP( Destination,PriceTbl[Destination], SWITCH(Class, "First",PriceTbl[First], "Economy",PriceTbl[Economy]) )
PeterBartholomew1
Apr 13, 2022Silver Contributor
Or then, to pursue my interests rather than the user requirement,
= Priceλ(Destination,Class)
where
Priceλ = LAMBDA(dest, cl,
LET(
priceList, SWITCH(
cl,
"First", PriceTbl[First],
"Economy", PriceTbl[Economy]
),
XLOOKUP(Dest, PriceTbl[Destination], priceList)
)
);