Index > Match across broad (Column:Row) range

sanantonio

Board Regular
Joined
Oct 26, 2021
Messages
124
Office Version
  1. 365
Platform
  1. Windows
Hi All,

So I have a data set where items by day report back their sales, write offs etc. (Sheet1)
1701964783682.png


For reasons unsaid I need not the date of the sale but the day after launch. EG:

Item 1 was launched 26/12/2022, therefore in the picture above column S would say "Day 2".

I have the date of each "day after launch" in another worksheet: (Sheet2)

1701964962876.png


I have tried my trusty Index(Match) formula but it won't work. I'm presuming because of the range. My formula is in S4 on sheet1 thus:

Excel Formula:
=index(Sheet2!F3:U3,match(1,index((F4=Sheet2!B4:B999)*(H4=Sheet2!F4:U999),0,1),0))

Any ideas?
 

Attachments

  • 1701964871978.png
    1701964871978.png
    56.7 KB · Views: 7

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
A simpler example to illustrate. Assume this on Sheet2:
Book4
BCDEFGHIJ
3abcde
4123456
5289101112
631415161718
Sheet2

Then for Sheet1, the row index of interest first needs to be isolated:
Excel Formula:
MATCH($F4,Sheet2!$B$4:$B$999,0)
...so that the entire row necessary for the next comparison/matching can be identified...the row is isolated with this part of the formula (note the comma at the end, which is necessary):
Excel Formula:
INDEX(Sheet2!$F$4:$U$999,MATCH($F4,Sheet2!$B$4:$B$999,0),)
Then that isolated row is used to perform the date matching, although I'm not certain about this. My example uses an exact match with H4, but you might need a different type of match. I can't tell from the images you pasted. In any case, this matching step identifies the column index, which is then used to return the answer from F3:U3...
Excel Formula:
=INDEX(Sheet2!$F$3:$U$3,,MATCH($H4,INDEX(Sheet2!$F$4:$U$999,MATCH($F4,Sheet2!$B$4:$B$999,0),),0))
Book4
FGHRS
415d
Sheet1
Cell Formulas
RangeFormula
S4S4=INDEX(Sheet2!$F$3:$U$3,,MATCH($H4,INDEX(Sheet2!$F$4:$U$999,MATCH($F4,Sheet2!$B$4:$B$999,0),),0))

You could do this with some Excel 365 functions if desired, but post back about the date-matching issue I mentioned.
 
Upvote 0
Hi. Thanks for responding.

I'm really sorry I'm totally lost with your explanation above. I must be doing something wrong as I can't get any of the formulas you posted to work, even though I've created an example that looks like yours.

Sheet2:
1702055506454.png


Sheet1:
1702055520532.png
 
Upvote 0
Note that what I posted was roughly laid out similar to your original screenshots. The upper left cell in my posting of Sheet2 is B3, meaning that the a,b,c,d "headings" of interest are in row 3 with the numbers involved in matching found in rows 4 and down. I can't tell from your most recent posting whether you've done this. To avoid this type of issue, you might consider using the XL2BB add-in for exchanging small portions of your file. You should be able to copy my content directly by clicking on the small clipboard icon in the upper left of each snippet (which copies that snippet to your clipboard), then go to an empty worksheet, navigate to the same cell corresponding to the upper left of the snippet (B3 of Sheet2 for example) and paste. That places the content of the snippet and any formulas directly into your sheet.
 
Upvote 0
From what I can guess, you have the Date of Sale in the Date column (col H) of Sheet1. Is that correct? And for Item 1 that date is shown as 27/12/2022 in cell H something...H3 maybe...I can't tell from the image.

You mentioned that Item 1 was launched 26/12/2022, but I don't see where that information comes from. I do not believe that is shown anywhere.

You want the "day after launch", which apparently is what Sheet2 shows. Yet Sheet2 shows a launch date (cell E4) of 19/12/2022 for Item 1...so I am confused. Was Item 1 "launched" on 26/12/2022 or 19/12/2022. If you want the "day after launch" could you simply add 1 to the date?

So I am not sure whether Sheet1 column H should be used at all. Assuming a date of interest appears on Sheet1 Column H (which I'll call the target date), I believe you want to find the smallest date that is larger than the target date and return the Day number associated with it. If that is true, then the exact match option is not correct, and none of the options readily available from match will work either, because they will find values that are either "exact or larger", or "exact or smaller". So these other options will still potentially find an exact match, which you do not want. Instead, you'll have to take a different approach. This is most easily done using some Excel 365 functions, although you can make it work with some additional logic in MATCH, and then you would need to find the minimum, etc.

After addressing these issues, then if a lookup is still needed (similar to the INDEX/MATCH shown earlier, except the min-greater-than-target condition needs to be applied), you could try something like this:
MrExcel_20231208.xlsx
ABCDEFGHIJKLM
3abcdefg
412345768
52891011121314
6314151617181920
Sheet2

MrExcel_20231208.xlsx
FGHRS
415f
Sheet1
Cell Formulas
RangeFormula
S4S4=LET(itm,Sheet2!$B$4:$B$9,day,Sheet2!$F$3:$U$3,data,Sheet2!$F$4:$U$9,irow,FILTER(data,itm=$F4),a,FILTER(VSTACK(day,irow),irow>H4),TAKE(SORTBY(a,TAKE(a,-1)),1,1))


If you are unfamiliar with these functions, they essentially find the item row of interest and isolate it as the variable named irow. The day array in row 3 is called "day". We stack these two together vertically, and then filter them to show only the columns where the dates in irow are greater than the date in H4. Then we sort the result by the dates remaining and take the day associated with the smallest date.
 
Upvote 0
Solution
Still rightly confused (I'm a simple soul) but the formula from your second post works a treat! Thank you very much
 
Upvote 0
That’s good to hear…I’m happy to help.
 
Upvote 0

Forum statistics

Threads
1,215,092
Messages
6,123,063
Members
449,090
Latest member
fragment

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