简体   繁体   中英

Issue with a multiple criteria INDEX MATCH formula

so I used this array formula with INDEX MATCH:

{=INDEX(ENTRIES!$F$4:$F$28;MATCH(C4&F4&G4;ENTRIES!$C$4:$C$28&ENTRIES!$G$4:$G$28&ENTRIES!$H$4:$H$28;0))}

Here is the thing, I was trying to display the price of the "entries" sheet on the "sales" sheet, the problem comes up when there are different prices for one "Code" or product over time. I tried to solve it with an Index Match formula (above) that matches the price of the code (product) with the month and the year but it doesn't assign the price or any value on the months between the updates of the price. see picture

example: for month 6 it should assign the price of month 5 because there is not any update or change. and the same for month 9 it should be the same e of the month 8 for that product. How can I do that?

Looks to me like it's throwing those errors because it won't be able to find these months. In all cases these months are missing, at least with your data, you could tell the formula to pick the maximum row from the data that is below or equal to your search month using MAX()

Furthermore, matching multiple criteria through concatenating cells and columns can get tricky once numeric values/dates are involves and could throw back wrong/unexpected results. Try something along these lines instead:

MATCH(1,((Criteria1)*(Criteria2)*(Criteria3))...

So the whole thing would look like:

=INDEX(ENTRIES!$F$1:$F$28;MAX(((ENTRIES!$C$4:$C$28=C4)*(ENTRIES!$G$4:$G$28<=G4)*(ENTRIES!$H$4:$H$28=H4)*ROW(ENTRIES!$F$4:$F$28))))

Entered through Ctrl Shift Enter

@JVDV answer was helpful, but it didn't work for me because it gives me a higher value instead of the latest price for the last month known not the next one.

Anyway looking at your formula, I finally came up with this:

{=IFERROR((INDEX(ENTRIES!$F$4:$F$28;MATCH(C8&J8&K8;ENTRIES!$C$4:$C$28&ENTRIES!$G$4:$G$28&ENTRIES!$H$4:$H$28;0)));INDEX(ENTRIES!$F$4:$F$28;MATCH(1;(ENTRIES!$C$4:$C$28=C8)*(ENTRIES!$G$4:$G$28=J8-1)*(ENTRIES!$H$4:$H$28=K8);0)))}

The first part is my original formula but now when it throws an error applies the second INDEX which finds the price of the month before the month with no price in the data. Of course, it's isn't perfect either because I have to "update" the price at least every two months.

I tried another way with a <= sign but it didn't work either.

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