Lookup values with two multiple criterias

Kamran01

Board Regular
Joined
Feb 10, 2017
Messages
86
Dear Experts,

I have a data sheet, as i attached a link of image below.

C3:J3 has dates from 19/2 till 27/2.

[TABLE="width: 500"]
<tbody>[TR]
[TD]Cell Address
[/TD]
[TD]Code
[/TD]
[TD]Consumption Range
[/TD]
[TD]Expected Purchase Range
[/TD]
[/TR]
[TR]
[TD]A4
[/TD]
[TD]01040001
[/TD]
[TD]C8:J8
[/TD]
[TD]C5:J5
[/TD]
[/TR]
[TR]
[TD]A12
[/TD]
[TD]03010003
[/TD]
[TD]C16:J16
[/TD]
[TD]C13:J13
[/TD]
[/TR]
[TR]
[TD]A20
[/TD]
[TD]11030009
[/TD]
[TD]C24:J24
[/TD]
[TD]C21:J21
[/TD]
[/TR]
</tbody>[/TABLE]

I want to calculate the sum of item based on Code & specfic date in Cosumption and Expected Purcahse.

I tried below code and got perfect result, but it is too long to remeber. Please suggest shortest code to calcuate.

=IF(A3="","",IF(A3=MRP!$A$4,INDEX(MRP!$C$8:$J$8,MATCH('Final Summary'!$F$1,MRP!$C$3:$J$3,0)),IF(A3=MRP!$A$12,INDEX(MRP!$C$16:$J$16,MATCH('Final Summary'!$F$1,MRP!$C$3:$J$3,0)),IF(A3=MRP!$A$20,INDEX(MRP!$C$24:$J$24,MATCH('Final Summary'!$F$1,MRP!$C$3:$J$3,0))))))

 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Instead of IF(INDEX(MATCH)),IF(INDEX(MATCH,IF(INDEX(MATCH)
just take the IFs out and place them in the INDEX()
so it's INDEX(IF(IF(,)),MATCH)

like this

=IF(A3="","",INDEX(IF(A3=MRP!$A$4,MRP!$C$8:$J$8,IF(A3=MRP!$A$12,MRP!$C$16:$J$16,MRP!$C$24:$J$24)),MATCH('Final Summary'!$F$1,MRP!$C$3:$J$3,0)))
 
Last edited:
Upvote 0
Well done, Formula working correctly.
Can you please describe the functions seperately.

Thanks,
Kamran Noor
 
Upvote 0
It's exactly the same formula but in a different order making it shorter.

You have
IF(A3=MRP!A4 then INDEX(MRP!C8:J8 MATCH Final Summary!F1,MRP!C3:J3,0)
IF(A3=MRP!A12 then INDEX(MRP!C16:J16 MATCH Final Summary!F1,MRP!C3:J3,0)
IF(A3=MRP!A16 then INDEX(MRP!C24:J24 MATCH Final Summary!F1,MRP!C3:J3,0)

The MATCH is the same regardless of what range is looked at
So the IF conditions can be put in the INDEX

So I've just changed it to

INDEX(
IF(A3=MRP!A4 then MRP!C8:J8
IF(A3=MRP!A12 then MRP!C16:J16
MRP!C24:J24))
,MATCH(Final Summary!F1,MRP!C3:J3,0)))
 
Upvote 0
Dear Special - K99,

Thank you for your perfect description, can you please confirm do we have another formula to lookup this value via sumproduct, Offset, sumifs, vlookup & any other functions.
 
Upvote 0
You asked for a shorter formula.
I provided a shorter formula.

I don't know of any others that would do it.
 
Upvote 0

Forum statistics

Threads
1,224,821
Messages
6,181,163
Members
453,021
Latest member
Justyna P

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