Index Match Date and Month

SAXON10

Board Regular
Joined
Jun 1, 2017
Messages
109
Hi,

How to index match with date and month ranges. I am looking for two different output based on the following data.

1. Date wise

2.Month wise

I apply the following formula in I3==IF(MATCH($G$3,$A$3:$A$1000,0),INDEX(DATA!$C$3:$E$1000,MATCH($H3,DATA!$B$3:$B$1000,0),MATCH(I$2,DATA!

$C$2:$E$2,0))) but I got wrong output.

Data Range:A2:A11 and Output Range:G2:K10

https://www.dropbox.com/s/cfeq8vfcr9pvaq6/INMA.PNG?dl=0

Any help much appreciated.


DATAOUTPUT
DATECOUNTRYAPPLEBANANABILBERRYDATECOUNTRYAPPLEBANANABILBERRYDATE WISE
01/01/2018UK158502/01/2018UK1585
US54824 US54824
EU7844446 EU7844446
02/01/2018UK484848
US212112DATECOUNTRYAPPLEBANANABILBERRYMONTHWISE
EU11111515Jan-18UK5010754
03/01/2018UK111 US277037
US111 EU90561962
EU111

<colgroup><col span="2"><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
If your data had the dates on every row, it would be really easy to solve both your problems with SUMPRODUCT or SUMIFS.

As it is, you should get the daily figures with

=INDEX(C$3:C$11,MATCH($G$3,$A$3:$A$11,0)+MATCH($H3,$H$3:$H$5,0)-1)

If your products in Data table were in different order than in your Output table, you'd have to use MATCH to find the right column as well but since they're in the same order I've left that part out to make the formula easier to read / understand.

The first MATCH in the formula finds the right date row but since there's also the Country column you need to add another MATCH for the country as well. And since the Country match returns 1 for UK and UK in your data is on the same row as your date, you need to subtract 1 from the second MATCH.

The monthly figures with empty rows in the data are much harder to calculate. A simple

=SUMPRODUCT(--(MONTH($A$3:$A$11)=MONTH($G$8)),--($B$3:$B$11=$H8),C$3:C$11)

returns correct numbers for January but only because the empty cells return 1 for the month number (Day 0 in Excel stands for January 0 1900 [or 1904, if you happen to be using the 1904 date system]).

If there's a row for each date - especially for the first date of each month - something like

=SUMPRODUCT(--(ROW($A$3:$A$11)>=ROW($A$2)+MATCH($G$8,$A$3:$A$11,0)),--(ROW($A$3:$A$11)<row($a$2)+match(eomonth($g$8,0)+1,$a$3:$a$11)),--($b$3:$b$11=$h8),c$3:c$11)


should work. G8 in this formula is supposed to always be the first of month and unlike the INDEX / MATCH solution this one can handle the year as well (the INDEX / MATCH only looked for the MONTH).

The first part of the formula makes sure the ROW is greater or equal to the first match of the dates (+ the header row unless you start your match from the first row of your worksheet as well). The second part makes sure the ROW is less than the MATCH for February 1st. The rest of the formula is just making sure the Country matches etc.</row($a$2)+match(eomonth($g$8,0)+1,$a$3:$a$11)),--($b$3:$b$11=$h8),c$3:c$11)
 
Last edited:
Upvote 0
Much appreciated for your help.

Thanks for considered my thread and clarify index match function. I follow-up your suggestion and formulas are working well.


You are legend.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,618
Messages
6,120,544
Members
448,970
Latest member
kennimack

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