Excel formula (Avg the difference) - excel

I have an excel file with 5 columns Year1%,Year2,Year3%, and I added the the 4th column to get the avg for each day for all 3 years, now I need to find formula to avg the difference between each day in year1 and the Avg, year2 and the Avg, and Year3 and the Avg,this is how my columns look like:
Year1 % _ Year2% _ Year3% _ Avg% _ Avg Diff to %
Day 1
Day 2
...

Assuming your table starts in A1, this formulas goes into the first row of the 5th data column (F2) to give you the average "DIFFERENCE" from the average:
=AVERAGE(E2-B2:D2)
This is an array formula that must be saved by pressing CTRL+SHIFT+ENTER
Note that this will always equal 0 (maybe showing rounding error due to Excel working with floating point precision)
This is due to the definition of the average being the point that is, on average, the same distance from all other points. The positive and negative differences all sum to zero.
If, however, you wanted the average "DISTANCE" from the average (taking only the magnitude of the difference), you would use this formula:
=AVERAGE(ABS(E2-B2:D2))
This is also an array formula.
Statistically, this is not an effective measure of the spread of data. A more effective measure comes from squaring the difference rather than taking the absolute value:
=AVERAGE((E2-B2:D2)^2)
But this is actually just the variance:
=VAR.P(B2:D2)
The square root of which is the Standard Deviation:
=STDEV.P(B2:D2)

Related

Excel: SUMPRODUCT with percentages

I use the following formula to calculate the SUMPRODUCT of the values in a column with the condition that there is a match between B2:B6 and A1:A3 (shoutout to user:8162520).
=SUMPRODUCT(($B$1:$B$6=$A$9)*(G2:G6))
Now however I would like to subtract to that result the percentage in C1 and/or D1, and "give it" to one of the other blue numbers, again with the condition that there is a match between C2:C6 or D2:D6 and A7:A9.
So for example in G7 the result for "1" should be 50% of 10 + 75% of 5, because "2" takes 50% of 10(G2) and "3" takes 25% of 5(G5).
The point is to create an overview of how many hours employees (1,2,3) have to spend spend on project B2:B6 for each week (E,F,G), and what happens if other employees take a certain percentage of the workload (C,D). What is the most efficient way to do this?
The numbers in A, B,C, D are reference numbers, they should not be part of the calculation. Maybe it's clearer if I use letters. See also the right results for E7:G7. The outcome must be the sum of the values in each column (workload) minus the percentage in C and D IF there is someone sharing the workload:
So deducting the percentage in C1:D1, presumably where there is no workload the result should be zero?
=SUMPRODUCT(($B$2:$B$6=$A7)*($C$2:$D$6<>"")*(1-$C$1:$D$1)*G$2:G$6)

Calculate maximum of a subrange in a table based on multiple conditions

I want to calculate the maximum amount of rain fallen on a day.
Column B contains the date as YYYYMMDD (value, not text)
Column C contains the number of the hour of measurement (ranging from 1 until 24)
Column N contains the amount of rain fallen in [mm] : 0 if no rain; positive integer if rain has fallen
What formula calculates the maximum amount of rain fallen on a day?
So:
for january 4th I want to sum N2:N25
for january 5th I want to sum N26:N49
etc.
and return the maximum of those calculated values
REMARK:
a value of -1 in column N indicates 'not measured' and shoudl be treated as 'no rain' (= 0)
I found one, my testing area only extended 1,000 rows, but it should scale nicely.
=MAX(SUMIFS(N2:N1000,B2:B1000,B2:B1000))
Remember to enter as an array formula by confirming with CNTRL + SHIFT + ENTER
Here's an ugly solution that takes 3 cells, but is much faster than my first formula:
=MAX(SUMIF(N2:N25,">"&0),SUMIF(N26:N49,">"&0),SUMIF(N50:N73,">"&0),SUMIF(N74:N97,">"&0),SUMIF(N98:N121,">"&0),SUMIF(N122:N145,">"&0),SUMIF(N146:N169,">"&0),SUMIF(N170:N193,">"&0),SUMIF(N194:N217,">"&0),SUMIF(N218:N241,">"&0),SUMIF(N242:N265,">"&0),SUMIF(N266:N289,">"&0),SUMIF(N290:N313,">"&0),SUMIF(N314:N337,">"&0),SUMIF(N338:N361,">"&0),SUMIF(N362:N385,">"&0),SUMIF(N386:N409,">"&0),SUMIF(N410:N433,">"&0),SUMIF(N434:N457,">"&0),SUMIF(N458:N481,">"&0),SUMIF(N482:N505,">"&0),SUMIF(N506:N529,">"&0),SUMIF(N530:N553,">"&0),SUMIF(N554:N577,">"&0),SUMIF(N578:N601,">"&0),SUMIF(N602:N625,">"&0),SUMIF(N626:N649,">"&0),SUMIF(N650:N673,">"&0),SUMIF(N674:N697,">"&0),SUMIF(N698:N721,">"&0),SUMIF(N722:N745,">"&0),SUMIF(N746:N769,">"&0),SUMIF(N770:N793,">"&0),SUMIF(N794:N817,">"&0),SUMIF(N818:N841,">"&0),SUMIF(N842:N865,">"&0),SUMIF(N866:N889,">"&0),SUMIF(N890:N913,">"&0),SUMIF(N914:N937,">"&0),SUMIF(N938:N961,">"&0),SUMIF(N962:N985,">"&0),SUMIF(N986:N1009,">"&0),SUMIF(N1010:N1033,">"&0),SUMIF(N1034:N1057,">"&0),SUMIF(N1058:N1081,">"&0),SUMIF(N1082:N1105,">"&0),SUMIF(N1106:N1129,">"&0),SUMIF(N1130:N1153,">"&0),SUMIF(N1154:N1177,">"&0),SUMIF(N1178:N1201,">"&0),SUMIF(N1202:N1225,">"&0),SUMIF(N1226:N1249,">"&0),SUMIF(N1250:N1273,">"&0),SUMIF(N1274:N1297,">"&0),SUMIF(N1298:N1321,">"&0),SUMIF(N1322:N1345,">"&0),SUMIF(N1346:N1369,">"&0),SUMIF(N1370:N1393,">"&0),SUMIF(N1394:N1417,">"&0),SUMIF(N1418:N1441,">"&0),SUMIF(N1442:N1465,">"&0),SUMIF(N1466:N1489,">"&0),SUMIF(N1490:N1513,">"&0),SUMIF(N1514:N1537,">"&0),SUMIF(N1538:N1561,">"&0),SUMIF(N1562:N1585,">"&0),SUMIF(N1586:N1609,">"&0),SUMIF(N1610:N1633,">"&0),SUMIF(N1634:N1657,">"&0),SUMIF(N1658:N1681,">"&0),SUMIF(N1682:N1705,">"&0),SUMIF(N1706:N1729,">"&0),SUMIF(N1730:N1753,">"&0),SUMIF(N1754:N1777,">"&0),SUMIF(N1778:N1801,">"&0),SUMIF(N1802:N1825,">"&0),SUMIF(N1826:N1849,">"&0),SUMIF(N1850:N1873,">"&0),SUMIF(N1874:N1897,">"&0),SUMIF(N1898:N1921,">"&0),SUMIF(N1922:N1945,">"&0),SUMIF(N1946:N1969,">"&0),SUMIF(N1970:N1993,">"&0),SUMIF(N1994:N2017,">"&0),SUMIF(N2018:N2041,">"&0),SUMIF(N2042:N2065,">"&0),SUMIF(N2066:N2089,">"&0),SUMIF(N2090:N2113,">"&0),SUMIF(N2114:N2137,">"&0),SUMIF(N2138:N2161,">"&0),SUMIF(N2162:N2185,">"&0),SUMIF(N2186:N2209,">"&0),SUMIF(N2210:N2233,">"&0),SUMIF(N2234:N2257,">"&0),SUMIF(N2258:N2281,">"&0),SUMIF(N2282:N2305,">"&0),SUMIF(N2306:N2329,">"&0),SUMIF(N2330:N2353,">"&0),SUMIF(N2354:N2377,">"&0),SUMIF(N2378:N2401,">"&0),SUMIF(N2402:N2425,">"&0),SUMIF(N2426:N2449,">"&0),SUMIF(N2450:N2473,">"&0),SUMIF(N2474:N2497,">"&0),SUMIF(N2498:N2521,">"&0),SUMIF(N2522:N2545,">"&0),SUMIF(N2546:N2569,">"&0),SUMIF(N2570:N2593,">"&0),SUMIF(N2594:N2617,">"&0),SUMIF(N2618:N2641,">"&0),SUMIF(N2642:N2665,">"&0),SUMIF(N2666:N2689,">"&0),SUMIF(N2690:N2713,">"&0),SUMIF(N2714:N2737,">"&0),SUMIF(N2738:N2761,">"&0),SUMIF(N2762:N2785,">"&0),SUMIF(N2786:N2809,">"&0),SUMIF(N2810:N2833,">"&0),SUMIF(N2834:N2857,">"&0),SUMIF(N2858:N2881,">"&0),SUMIF(N2882:N2905,">"&0),SUMIF(N2906:N2929,">"&0),SUMIF(N2930:N2953,">"&0),SUMIF(N2954:N2977,">"&0),SUMIF(N2978:N3001,">"&0),SUMIF(N3002:N3025,">"&0),SUMIF(N3026:N3049,">"&0),SUMIF(N3050:N3073,">"&0),SUMIF(N3074:N3097,">"&0),SUMIF(N3098:N3121,">"&0),SUMIF(N3122:N3145,">"&0),SUMIF(N3146:N3169,">"&0),SUMIF(N3170:N3193,">"&0),SUMIF(N3194:N3217,">"&0),SUMIF(N3218:N3241,">"&0),SUMIF(N3242:N3265,">"&0),SUMIF(N3266:N3289,">"&0),SUMIF(N3290:N3313,">"&0),SUMIF(N3314:N3337,">"&0),SUMIF(N3338:N3361,">"&0),SUMIF(N3362:N3385,">"&0),SUMIF(N3386:N3409,">"&0),SUMIF(N3410:N3433,">"&0),SUMIF(N3434:N3457,">"&0),SUMIF(N3458:N3481,">"&0),SUMIF(N3482:N3505,">"&0),SUMIF(N3506:N3529,">"&0),SUMIF(N3530:N3553,">"&0),SUMIF(N3554:N3577,">"&0),SUMIF(N3578:N3601,">"&0),SUMIF(N3602:N3625,">"&0),SUMIF(N3626:N3649,">"&0),SUMIF(N3650:N3673,">"&0),SUMIF(N3674:N3697,">"&0),SUMIF(N3698:N3721,">"&0),SUMIF(N3722:N3745,">"&0),SUMIF(N3746:N3769,">"&0),SUMIF(N3770:N3793,">"&0),SUMIF(N3794:N3817,">"&0),SUMIF(N3818:N3841,">"&0),SUMIF(N3842:N3865,">"&0),SUMIF(N3866:N3889,">"&0),SUMIF(N3890:N3913,">"&0),SUMIF(N3914:N3937,">"&0),SUMIF(N3938:N3961,">"&0),SUMIF(N3962:N3985,">"&0),SUMIF(N3986:N4009,">"&0),SUMIF(N4010:N4033,">"&0),SUMIF(N4034:N4057,">"&0),SUMIF(N4058:N4081,">"&0),SUMIF(N4082:N4105,">"&0),SUMIF(N4106:N4129,">"&0),SUMIF(N4130:N4153,">"&0),SUMIF(N4154:N4177,">"&0),SUMIF(N4178:N4201,">"&0),SUMIF(N4202:N4225,">"&0),SUMIF(N4226:N4249,">"&0),SUMIF(N4250:N4273,">"&0),SUMIF(N4274:N4297,">"&0),SUMIF(N4298:N4321,">"&0),SUMIF(N4322:N4345,">"&0),SUMIF(N4346:N4369,">"&0),SUMIF(N4370:N4393,">"&0),SUMIF(N4394:N4417,">"&0),SUMIF(N4418:N4441,">"&0),SUMIF(N4442:N4465,">"&0),SUMIF(N4466:N4489,">"&0),SUMIF(N4490:N4513,">"&0),SUMIF(N4514:N4537,">"&0),SUMIF(N4538:N4561,">"&0),SUMIF(N4562:N4585,">"&0),SUMIF(N4586:N4609,">"&0),SUMIF(N4610:N4633,">"&0),SUMIF(N4634:N4657,">"&0),SUMIF(N4658:N4681,">"&0),SUMIF(N4682:N4705,">"&0),SUMIF(N4706:N4729,">"&0),SUMIF(N4730:N4753,">"&0),SUMIF(N4754:N4777,">"&0),SUMIF(N4778:N4801,">"&0),SUMIF(N4802:N4825,">"&0),SUMIF(N4826:N4849,">"&0),SUMIF(N4850:N4873,">"&0),SUMIF(N4874:N4897,">"&0),SUMIF(N4898:N4921,">"&0),SUMIF(N4922:N4945,">"&0),SUMIF(N4946:N4969,">"&0),SUMIF(N4970:N4993,">"&0),SUMIF(N4994:N5017,">"&0),SUMIF(N5018:N5041,">"&0),SUMIF(N5042:N5065,">"&0),SUMIF(N5066:N5089,">"&0),SUMIF(N5090:N5113,">"&0),SUMIF(N5114:N5137,">"&0),SUMIF(N5138:N5161,">"&0),SUMIF(N5162:N5185,">"&0),SUMIF(N5186:N5209,">"&0),SUMIF(N5210:N5233,">"&0),SUMIF(N5234:N5257,">"&0))
And in a separate cell
=MAX(SUMIF(N5258:N5281,">"&0),SUMIF(N5282:N5305,">"&0),SUMIF(N5306:N5329,">"&0),SUMIF(N5330:N5353,">"&0),SUMIF(N5354:N5377,">"&0),SUMIF(N5378:N5401,">"&0),SUMIF(N5402:N5425,">"&0),SUMIF(N5426:N5449,">"&0),SUMIF(N5450:N5473,">"&0),SUMIF(N5474:N5497,">"&0),SUMIF(N5498:N5521,">"&0),SUMIF(N5522:N5545,">"&0),SUMIF(N5546:N5569,">"&0),SUMIF(N5570:N5593,">"&0),SUMIF(N5594:N5617,">"&0),SUMIF(N5618:N5641,">"&0),SUMIF(N5642:N5665,">"&0),SUMIF(N5666:N5689,">"&0),SUMIF(N5690:N5713,">"&0),SUMIF(N5714:N5737,">"&0),SUMIF(N5738:N5761,">"&0),SUMIF(N5762:N5785,">"&0),SUMIF(N5786:N5809,">"&0),SUMIF(N5810:N5833,">"&0),SUMIF(N5834:N5857,">"&0),SUMIF(N5858:N5881,">"&0),SUMIF(N5882:N5905,">"&0),SUMIF(N5906:N5929,">"&0),SUMIF(N5930:N5953,">"&0),SUMIF(N5954:N5977,">"&0),SUMIF(N5978:N6001,">"&0),SUMIF(N6002:N6025,">"&0),SUMIF(N6026:N6049,">"&0),SUMIF(N6050:N6073,">"&0),SUMIF(N6074:N6097,">"&0),SUMIF(N6098:N6121,">"&0),SUMIF(N6122:N6145,">"&0),SUMIF(N6146:N6169,">"&0),SUMIF(N6170:N6193,">"&0),SUMIF(N6194:N6217,">"&0),SUMIF(N6218:N6241,">"&0),SUMIF(N6242:N6265,">"&0),SUMIF(N6266:N6289,">"&0),SUMIF(N6290:N6313,">"&0),SUMIF(N6314:N6337,">"&0),SUMIF(N6338:N6361,">"&0),SUMIF(N6362:N6385,">"&0),SUMIF(N6386:N6409,">"&0),SUMIF(N6410:N6433,">"&0),SUMIF(N6434:N6457,">"&0),SUMIF(N6458:N6481,">"&0),SUMIF(N6482:N6505,">"&0),SUMIF(N6506:N6529,">"&0),SUMIF(N6530:N6553,">"&0),SUMIF(N6554:N6577,">"&0),SUMIF(N6578:N6601,">"&0),SUMIF(N6602:N6625,">"&0),SUMIF(N6626:N6649,">"&0),SUMIF(N6650:N6673,">"&0),SUMIF(N6674:N6697,">"&0),SUMIF(N6698:N6721,">"&0),SUMIF(N6722:N6745,">"&0),SUMIF(N6746:N6769,">"&0),SUMIF(N6770:N6793,">"&0),SUMIF(N6794:N6817,">"&0),SUMIF(N6818:N6841,">"&0),SUMIF(N6842:N6865,">"&0),SUMIF(N6866:N6889,">"&0),SUMIF(N6890:N6913,">"&0),SUMIF(N6914:N6937,">"&0),SUMIF(N6938:N6961,">"&0),SUMIF(N6962:N6985,">"&0),SUMIF(N6986:N7009,">"&0),SUMIF(N7010:N7033,">"&0),SUMIF(N7034:N7057,">"&0),SUMIF(N7058:N7081,">"&0),SUMIF(N7082:N7105,">"&0),SUMIF(N7106:N7129,">"&0),SUMIF(N7130:N7153,">"&0),SUMIF(N7154:N7177,">"&0),SUMIF(N7178:N7201,">"&0),SUMIF(N7202:N7225,">"&0),SUMIF(N7226:N7249,">"&0),SUMIF(N7250:N7273,">"&0),SUMIF(N7274:N7297,">"&0),SUMIF(N7298:N7321,">"&0),SUMIF(N7322:N7345,">"&0),SUMIF(N7346:N7369,">"&0),SUMIF(N7370:N7393,">"&0),SUMIF(N7394:N7417,">"&0),SUMIF(N7418:N7441,">"&0),SUMIF(N7442:N7465,">"&0),SUMIF(N7466:N7489,">"&0),SUMIF(N7490:N7513,">"&0),SUMIF(N7514:N7537,">"&0),SUMIF(N7538:N7561,">"&0),SUMIF(N7562:N7585,">"&0),SUMIF(N7586:N7609,">"&0),SUMIF(N7610:N7633,">"&0),SUMIF(N7634:N7657,">"&0),SUMIF(N7658:N7681,">"&0),SUMIF(N7682:N7705,">"&0),SUMIF(N7706:N7729,">"&0),SUMIF(N7730:N7753,">"&0),SUMIF(N7754:N7777,">"&0),SUMIF(N7778:N7801,">"&0),SUMIF(N7802:N7825,">"&0),SUMIF(N7826:N7849,">"&0),SUMIF(N7850:N7873,">"&0),SUMIF(N7874:N7897,">"&0),SUMIF(N7898:N7921,">"&0),SUMIF(N7922:N7945,">"&0),SUMIF(N7946:N7969,">"&0),SUMIF(N7970:N7993,">"&0),SUMIF(N7994:N8017,">"&0),SUMIF(N8018:N8041,">"&0),SUMIF(N8042:N8065,">"&0),SUMIF(N8066:N8089,">"&0),SUMIF(N8090:N8113,">"&0),SUMIF(N8114:N8137,">"&0),SUMIF(N8138:N8161,">"&0),SUMIF(N8162:N8185,">"&0),SUMIF(N8186:N8209,">"&0),SUMIF(N8210:N8233,">"&0),SUMIF(N8234:N8257,">"&0),SUMIF(N8258:N8281,">"&0),SUMIF(N8282:N8305,">"&0),SUMIF(N8306:N8329,">"&0),SUMIF(N8330:N8353,">"&0),SUMIF(N8354:N8377,">"&0),SUMIF(N8378:N8401,">"&0),SUMIF(N8402:N8425,">"&0),SUMIF(N8426:N8449,">"&0),SUMIF(N8450:N8473,">"&0),SUMIF(N8474:N8497,">"&0),SUMIF(N8498:N8521,">"&0),SUMIF(N8522:N8545,">"&0),SUMIF(N8546:N8569,">"&0),SUMIF(N8570:N8593,">"&0),SUMIF(N8594:N8617,">"&0),SUMIF(N8618:N8641,">"&0),SUMIF(N8642:N8665,">"&0),SUMIF(N8666:N8689,">"&0),SUMIF(N8690:N8713,">"&0),SUMIF(N8714:N8737,">"&0),SUMIF(N8738:N8761,">"&0),SUMIF(N8762:N8785,">"&0))
The Max() of these two cells is the total for the year. It's brute force but it solves the speed issue.

How to calculate moving average 7 days of milk production of a each cow, Dates not sorted. Excel

The daily milk production of each cow is recorded daily. I would like to cancel out the noise. Therefore I would like to use a moving average of seven days ( 3 days before and 3 days after, including current date production) in Excel.
The data is not ordered according to date therefore offset function cannot be used.
Additional Information: "Date" is in Column A, Cow No in Column B and Milk in Column C . Rows are from 1-22.
The expected result would be get get a moving average of milk for 7 days of each cow ( -3 days before <=current date and < days+3 days after current date from each cow.
Similiar function used to calculate rolling average of past year is =AVERAGEIFS(B2:K2,B1:K1,">"&TODAY()-365,B1:K1,"<"&TODAY()). A similiar formula could be used.
Problem when using sumproduct formula: No Data for 7 days should be 0 7D Average. However is given 1.79 .Rolling AVerage with the Sumproduct formula Problem
You can try to use a combination of SUMPRODUCT and AVERAGE functions. Note that this is an array formula, so you need to enter it using Ctrl+Shift+Enter keys:
=SUMPRODUCT(AVERAGE(IF(($B$2:$B$22=B2)*($A$2:$A$22>=(A2-3))*($A$2:$A$22<=(A2+3)),$C$2:$C$22)))
Result:
The average for the first three entries (D2:D4) is exactly the same as the value in column C, as there are no other dates provided for the range between 23-29 January. The remaining values (D5:D22) should properly present the 7-day average values.
This may not be the pretiest solution but it works. We can use countifs in the following way:
1. Create a column that combines Cow no and Date (I called it CowNoDate) with the format CowNo + "-" + date(as number). I put it in column C.
2. Sort list by this new column
3. use the following formula in column E to calculate the running average:
=SUMIFS(D:D,C:C,">="&B2&"-"&(A2-3),C:C,"<="&B2&"-"&(A2+3))

How to achieve equal Sum Values horizontally and vertically in Excel

I'm working on this for a week now and still could not get the result I want. What I want is to have an equal result between the horizontal total and vertical total when summing up every columns in excel. Please consider this worksheet.
Every TSalary values in each row is equal to each values in its row in Gross Pay Columns. The same thing also in TDeductions with the columns in Deductions. However, after summing up each row and getting its overall total in AD13 & AE13, I am not getting the same value with the total when summing up every columns in gross pay and deductions.
In column AE you seem to have rounded each value to the nearer cent. In cell N13 you have summed the unrounded values.
The 4 half-cents (in column N) that have thus been rounded to a full cent cause your total to be 2 cents higher than the total of the unrounded amounts.
You need to be consistent when applying roundings if you wish your totals to be consistent.

INDEX/MATCH for closest value to a certain date

In sheet "Dividends" I have a table with dividends sorted by daily dates. E.g, columns A and B contain the following entries:
6/14/2015
6/13/2015
6/12/2015 0.045
6/11/2015
6/10/2015
This means that the stock paid a dividend of 0.045 on 6/12/2015.
In another sheet "AdjClose", I have a table with weekly dates and stock prices, e.g.
6/15/2015 1.23
6/8/2015 1.24
6/1/2015 1.06
5/30/2015 1.10
5/23/2015 1.22
5/16/2015 1.20
I would now compute the yield, where I divide the dividend by the stock price that is closest to the date of the dividend payout, but smaller than that date.
The result should be:
0.045/1.24
How could I do this? Many thanks for any input.
Following 4 named ranges for simplicity in code:
"Dividends": DividendDates (column A); DividendsPaid (column B)
"AdjClose": StockDate (column A); StockPrice (column B)
try (in column C in "Dividends":
{=INDEX(StockPrice;MATCH(MAX(IF((StockDates<=A1);StockDates));StockDates;0))}
Assuming that the dividend date for which you want to find the adjusted stock price is in cell A1.
And copy down for each dividend date. This will give you the stock price of the day closest to, but before, you dividend date (or on the date if it is the same). Then just devide by your dividend for that day (either in the formula I wrote, or in a separate column. Always good to show your calculations steps, so it is easier to follow.
And remember to press CTRL + SHIFT + ENTER when you enter the formula, not just ENTER, as it is an array formula.
EDIT: Also, you need to change the ; to , if that is the formula separator of your language.
Not the best looking one, but an option:
{=B3/INDEX(AdjClose!$B$1:$B$6,MATCH(MAX((AdjClose!$A$1:$A$6<=Dividends!A3)*AdjClose!$A$1:$A$6),AdjClose!$A$1:$A$6,0))}
Option #2 - much better, as there are no repeating ranges:
{=B3/INDEX(AdjClose!$B$1:$B$6,MATCH(1,--(AdjClose!$A$1:$A$6<=Dividends!A3),0))}

Resources