# Look up in table based on 4 values

Occasional Contributor

# Look up in table based on 4 values

I have a table of values that I need to look up using 4 values?

So it would first search / drill down on Stores, then Dept, then Product, then Start Range..

9 Replies

# Betreff: Look up in table based on 4 values

If I may ask, where do you get values from?
what result would you like to achieve with your project?

With your permission, if I can recommend. It can help us all if you upload an Excel file (without sensitive data), no picture. Even if it is said that a picture can say a thousand words, it is certainly not in the case of Excel, on the contrary in some cases. This would also be a blessing for all of us, as we can understand the problem much better, a win-win situation for everyone.

* Knowing the Excel version and operating system would also be an advantage.

Thank you for your understanding and patience

Nikolino

I know I don't know anything (Socrates)

# Betreff: Look up in table based on 4 values

@Nikolino Thank you for your reply and tips...  Attached is a sample.  The gray fields are the input fields.  If a customer shopped at Publix and bought 7 rolls the cost per roll would be \$.50 as indicated by the orange F3 cell.  Hope this helps...

# Betreff: Look up in table based on 4 values

As variant

in E14

``````=XLOOKUP(
D14,
(\$A\$2:\$A\$9&\$B\$2:\$B\$9&\$C\$2:\$C\$9=A14&B14&C14)*\$D\$2:\$D\$9,
\$F\$2:\$F\$9,
"no such",
-1
)``````

# Betreff: Look up in table based on 4 values

@Sergei Baklan Love this simple formula.  But what if the table value is spaces where the Dept does not apply... meaning the price is not dictate by Dept?   For example, Farmer Jacks; If the Customer enters Store = Farmer Jack, Product = Rolls, Dept = Baked Goods and if you look up in the tables Stores, Product and the Dept is spaces in the table, skip it and check Starting Range.   Otherwise, lookup the Stores, Product, Dept and Starting Range.

# Betreff: Look up in table based on 4 values

If I understood correctly result shall be

Hope you have LET function, when it could be

``````=LET( Quantity, D25,
Store, A25, Product, B25, Dept, C25,
Stores, \$A\$2:\$A\$20, Products, \$B\$2:\$B\$20, Depts, \$C\$2:\$C\$20,
startRange, \$D\$2:\$D\$20, priceEach, \$F\$2:\$F\$20,
shortCriteria, Store&Product, shortRange, Stores&Products,
noDpts, ISNA(XMATCH(Store&Product&Dept,Stores&Products&Depts)),
criteria, Store&Product & IF(noDpts, "", Dept),
lookupRange, Stores&Products &  IF(noDpts, "", Depts),
PricePerRoll, XLOOKUP(Quantity,(lookupRange=criteria)*startRange,priceEach,"no such", -1),
PricePerRoll)``````

IT could be without LET() - formula will be shorter but harder in maintenance

# Betreff: Look up in table based on 4 values

@Sergei Baklan Interesting.... the below spreadsheet doesnt work.  How do I know if I have the LET function?

# Betreff: Look up in table based on 4 values

In general LET() shall be available for all Office365 subscribers except ones on semi-annual channel. For them it shall be available at the beginning of next year. You may start typing in any empty cell =LE

If you see LET in the list you have it

Without LET() formula could be

``````=XLOOKUP(D25,
(\$A\$2:\$A\$20&\$B\$2:\$B\$20 &  IF(ISNA(XMATCH(A25&B25&C25,\$A\$2:\$A\$20&\$B\$2:\$B\$20&\$C\$2:\$C\$20)), "", \$C\$2:\$C\$20)=
A25&B25 & IF(ISNA(XMATCH(A25&B25&C25,\$A\$2:\$A\$20&\$B\$2:\$B\$20&\$C\$2:\$C\$20)), "", C25))*
\$D\$2:\$D\$20,
\$F\$2:\$F\$20,
"no such", -1
)``````

# Betreff: Look up in table based on 4 values

@Sergei Baklan  How can we code it if there is not Start Range?

Meaning the price does not depend on the quantity... see attached  Thanks greatly for your help!

# Betreff: Look up in table based on 4 values

We may modify the formula adding here

some small number which won't affect result of calculations.