Looking for a spilled formula returning the value in a table matching 3 conditions

ED38

New Member
Joined
Mar 29, 2024
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to apply the Map function I found out recently in the below describe situation but it does not work..
if someone could help me. Thank you

here is my formula in A5 (part of the array D5, in column E are the product code list and in F the quantity) :
=MAP(OFFSET(D5#;0;1;;1);Cost_Database[ProductCode];Cost_Database[MinQuantity];Cost_Database[MaxQuantity];Cost_Database[Tier];OFFSET(D5#;0;2;;1);LAMBDA(a;b;c;d;e;f;IF((a=b)*(c>=f)*(d<=f);e;"")))

I would like for each product code in my list get the name of the tier for which the qty matches the range of the tier.
I expect it is clear enough...
Let me know your proposal and potential explanation why my formula does not work ;-)

Thank you
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Your LAMBDA tests a=b, c>=f and d<=f.

Here's an illustration of a=b

Book1.xlsm
ABC
1aba=b
212FALSE
321FALSE
433TRUE
Sheet1
Cell Formulas
RangeFormula
C2:C4C2=a=b
Dynamic array formulas.
Named Ranges
NameRefers ToCells
a=Sheet1!$A$2:$A$4C2
b=Sheet1!$B$2:$B$4C2


It requires a and b to be the same size (I suspect yours will be different sizes) and the comparison is element by element, hence we don't get a match for a =1 or 2, even though both values are in b.

It's hard to be sure without seeing your layout, but I think this is one way that should work for you?

Excel Formula:
=BYROW(D5#;LAMBDA(r;XLOOKUP(1;(INDEX(r;2)=Cost_Database[ProductCode])*(INDEX(r;3)>=Cost_Database[MinQuantity])*(INDEX(r;3)<=Cost_Database[MaxQuantity]);Cost_Database[Tier];"n/a")))
 
Upvote 0
Solution
Thanks a lot Stephen.
Your formula works very well (as I expected!)
and thank you for the explanation on top.
 
Upvote 0
Hello StephenCrump,
In order to re-use your formula in similar context, I need to understand the usage of INDEX here as that function is supposed to work that way : INDEX(array, row,[column]).
With the 'BYROW' function ahead, I understand INDEX(r, 2) taht way : the 'r' = the value of the row in the 2nd column of the D5# array (the column matching the product code) BUT the '2' is placed at the position supposed to be for the Row#, not the column# so I am confused by this (or I maybe totally misunderstood the overall formula!)
Could you explain how it works please?
Thanks again
 
Upvote 0
When the array is one dimensional, you need to specify only the "row" argument.

But in this case, it's really the nth element, rather than the nth row:

ABCDEF
1AABCD
2B
3C3
4DCC
5CC
Sheet1
Cell Formulas
RangeFormula
C4C4=INDEX(C1:F1,C3)
D4D4=INDEX(C1:F1,1,C3)
C5C5=INDEX(A1:A4,C3)
D5D5=INDEX(A1:A4,C3,1)

If you like, you can specify the "1" for the missing dimension. It's just not necessary to do so.
 
Upvote 0
Thank you StephenCrump for the add'l explanation, that's clear!
Have a nice day
 
Upvote 0

Forum statistics

Threads
1,222,660
Messages
6,167,422
Members
452,112
Latest member
BPNuyttens

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top