Calculate average and max for specific dates

latorta

New Member
Joined
Apr 22, 2020
Messages
5
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I am stuck and can't figure out how to obtain the max and average using the Value column for a large dataset (300K+) using what I think is two criteria (Date, Type) I want to get the average and max for each type based on the unique dates. The type of data repeats, e.i, A, B, C, but it corresponds to different dates. I want each date to have its own average and max based on the data type. Below you can see what I mean.

I tried the following for the average, IF(A2=A1,"",AVERAGEIF($A$2:$A$73,A2,$E$2:$E$73)), but It gives me the average for everything that has the same date, so I know it's wrong. The code below shows what I need using average and max.


Book2.xlsx
ABCDE
1DateTypeAverageMaxValue
22019-01-01A2.4966666672.662.44
32019-01-01A2.4966666672.662.44
42019-01-01A2.4966666672.662.45
52019-01-01A2.4966666672.662.66
62019-01-01A2.4966666672.662.44
72019-01-01A2.4966666672.662.45
82019-01-01A2.4966666672.662.64
92019-01-01A2.4966666672.662.47
102019-01-01A2.4966666672.662.48
112019-01-01B0.0653333330.230.01
122019-01-01B0.0653333330.230.01
132019-01-01B0.0653333330.230.02
142019-01-01B0.0653333330.230.23
152019-01-01B0.0653333330.230.01
162019-01-01B0.0653333330.230.02
172019-01-01B0.0653333330.230.01
182019-01-01B0.0653333330.230.01
192019-01-01B0.0653333330.230.02
202019-01-01B0.0653333330.230.23
212019-01-01B0.0653333330.230.01
222019-01-01B0.0653333330.230.02
232019-01-01B0.0653333330.230.21
242019-01-01B0.0653333330.230.04
252019-01-01B0.0653333330.230.05
262019-01-01C0.21
272019-01-01C0.04
282019-01-01C0.05
292019-01-02A0.040.233.36
302019-01-02A0.040.233.36
312019-01-02A0.040.233.36
322019-01-02A0.040.233.5
332019-01-02A0.040.233.35
342019-01-02A0.040.233.36
352019-01-02A0.040.233.53
362019-01-02A0.040.233.35
372019-01-02B0.18
382019-01-02B0.05
392019-01-02B0.04
402019-01-02B0.05
412019-01-02B0.04
422019-01-02B0.04
432019-01-02B0.05
442019-01-02B5.7
452019-01-02C0.18
462019-01-02C0.05
472019-01-02C0.04
482019-01-02C0.05
492019-01-02C0.04
502019-01-02C0.04
512019-01-02C0.05
522019-01-02C5.7
532019-01-03A3.36
542019-01-03A3.35
552019-01-03A5.65
562019-01-03A5.66
572019-01-03A5.68
582019-01-03A5.68
592019-01-03A5.69
602019-01-03A3.94
612019-01-03A2.95
622019-01-03A0.02
632019-01-03A0.02
642019-01-03B3.94
652019-01-03B2.95
662019-01-03B0.02
672019-01-03B0.02
682019-01-03B0.02
692019-01-03B0.02
702019-01-03B3.36
712019-01-03C0.02
722019-01-03C0.02
732019-01-03C3.36
Sheet1
Cell Formulas
RangeFormula
C2:C10C2=AVERAGE($E$2:$E$10)
D2:D10D2=MAX($E$2:$E$10)
C11:C25C11=AVEDEV($E$11:$E$25)
D11:D25D11=MAX($E$11:$E$25)
C29:C36C29=AVERAGE($E$11:$E$18)
D29:D36D29=MAX($E$11:$E$18)
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Like this?

Book1
ABCDE
1DateTypeAverageMaxValue
21/1/2019A2.4966666672.662.44
31/1/2019A2.4966666672.662.44
41/1/2019A2.4966666672.662.45
51/1/2019A2.4966666672.662.66
61/1/2019A2.4966666672.662.44
71/1/2019A2.4966666672.662.45
81/1/2019A2.4966666672.662.64
91/1/2019A2.4966666672.662.47
101/1/2019A2.4966666672.662.48
111/1/2019B0.060.230.01
121/1/2019B0.060.230.01
131/1/2019B0.060.230.02
141/1/2019B0.060.230.23
151/1/2019B0.060.230.01
161/1/2019B0.060.230.02
171/1/2019B0.060.230.01
181/1/2019B0.060.230.01
191/1/2019B0.060.230.02
201/1/2019B0.060.230.23
211/1/2019B0.060.230.01
221/1/2019B0.060.230.02
231/1/2019B0.060.230.21
241/1/2019B0.060.230.04
251/1/2019B0.060.230.05
261/1/2019C0.10.210.21
271/1/2019C0.10.210.04
281/1/2019C0.10.210.05
291/2/2019A3.396253.533.36
301/2/2019A3.396253.533.36
311/2/2019A3.396253.533.36
321/2/2019A3.396253.533.5
331/2/2019A3.396253.533.35
341/2/2019A3.396253.533.36
351/2/2019A3.396253.533.53
361/2/2019A3.396253.533.35
371/2/2019B0.768755.70.18
381/2/2019B0.768755.70.05
391/2/2019B0.768755.70.04
401/2/2019B0.768755.70.05
411/2/2019B0.768755.70.04
421/2/2019B0.768755.70.04
431/2/2019B0.768755.70.05
441/2/2019B0.768755.75.7
451/2/2019C0.768755.70.18
461/2/2019C0.768755.70.05
471/2/2019C0.768755.70.04
481/2/2019C0.768755.70.05
491/2/2019C0.768755.70.04
501/2/2019C0.768755.70.04
511/2/2019C0.768755.70.05
521/2/2019C0.768755.75.7
531/3/2019A3.8181818185.693.36
541/3/2019A3.8181818185.693.35
551/3/2019A3.8181818185.695.65
561/3/2019A3.8181818185.695.66
571/3/2019A3.8181818185.695.68
581/3/2019A3.8181818185.695.68
591/3/2019A3.8181818185.695.69
601/3/2019A3.8181818185.693.94
611/3/2019A3.8181818185.692.95
621/3/2019A3.8181818185.690.02
631/3/2019A3.8181818185.690.02
641/3/2019B1.4757142863.943.94
651/3/2019B1.4757142863.942.95
661/3/2019B1.4757142863.940.02
671/3/2019B1.4757142863.940.02
681/3/2019B1.4757142863.940.02
691/3/2019B1.4757142863.940.02
701/3/2019B1.4757142863.943.36
711/3/2019C1.1333333333.360.02
721/3/2019C1.1333333333.360.02
731/3/2019C1.1333333333.363.36
Sheet1
Cell Formulas
RangeFormula
C2:C73C2=AVERAGEIFS($E$2:$E$73,$A$2:$A$73,$A2,$B$2:$B$73,$B2)
D2:D73D2=MAXIFS($E$2:$E$73,$A$2:$A$73,$A2,$B$2:$B$73,$B2)
 
Upvote 0
Like this?

Book1
ABCDE
1DateTypeAverageMaxValue
21/1/2019A2.4966666672.662.44
31/1/2019A2.4966666672.662.44
41/1/2019A2.4966666672.662.45
51/1/2019A2.4966666672.662.66
61/1/2019A2.4966666672.662.44
71/1/2019A2.4966666672.662.45
81/1/2019A2.4966666672.662.64
91/1/2019A2.4966666672.662.47
101/1/2019A2.4966666672.662.48
111/1/2019B0.060.230.01
121/1/2019B0.060.230.01
131/1/2019B0.060.230.02
141/1/2019B0.060.230.23
151/1/2019B0.060.230.01
161/1/2019B0.060.230.02
171/1/2019B0.060.230.01
181/1/2019B0.060.230.01
191/1/2019B0.060.230.02
201/1/2019B0.060.230.23
211/1/2019B0.060.230.01
221/1/2019B0.060.230.02
231/1/2019B0.060.230.21
241/1/2019B0.060.230.04
251/1/2019B0.060.230.05
261/1/2019C0.10.210.21
271/1/2019C0.10.210.04
281/1/2019C0.10.210.05
291/2/2019A3.396253.533.36
301/2/2019A3.396253.533.36
311/2/2019A3.396253.533.36
321/2/2019A3.396253.533.5
331/2/2019A3.396253.533.35
341/2/2019A3.396253.533.36
351/2/2019A3.396253.533.53
361/2/2019A3.396253.533.35
371/2/2019B0.768755.70.18
381/2/2019B0.768755.70.05
391/2/2019B0.768755.70.04
401/2/2019B0.768755.70.05
411/2/2019B0.768755.70.04
421/2/2019B0.768755.70.04
431/2/2019B0.768755.70.05
441/2/2019B0.768755.75.7
451/2/2019C0.768755.70.18
461/2/2019C0.768755.70.05
471/2/2019C0.768755.70.04
481/2/2019C0.768755.70.05
491/2/2019C0.768755.70.04
501/2/2019C0.768755.70.04
511/2/2019C0.768755.70.05
521/2/2019C0.768755.75.7
531/3/2019A3.8181818185.693.36
541/3/2019A3.8181818185.693.35
551/3/2019A3.8181818185.695.65
561/3/2019A3.8181818185.695.66
571/3/2019A3.8181818185.695.68
581/3/2019A3.8181818185.695.68
591/3/2019A3.8181818185.695.69
601/3/2019A3.8181818185.693.94
611/3/2019A3.8181818185.692.95
621/3/2019A3.8181818185.690.02
631/3/2019A3.8181818185.690.02
641/3/2019B1.4757142863.943.94
651/3/2019B1.4757142863.942.95
661/3/2019B1.4757142863.940.02
671/3/2019B1.4757142863.940.02
681/3/2019B1.4757142863.940.02
691/3/2019B1.4757142863.940.02
701/3/2019B1.4757142863.943.36
711/3/2019C1.1333333333.360.02
721/3/2019C1.1333333333.360.02
731/3/2019C1.1333333333.363.36
Sheet1
Cell Formulas
RangeFormula
C2:C73C2=AVERAGEIFS($E$2:$E$73,$A$2:$A$73,$A2,$B$2:$B$73,$B2)
D2:D73D2=MAXIFS($E$2:$E$73,$A$2:$A$73,$A2,$B$2:$B$73,$B2)

Oh man, YES! Thank you so much. I really appreciate it. This was driving me mad.:)(y)
I didn't realize I could use that function and set multiple criteria to reference and calculated what I needed.
 
Upvote 0
You're welcome. Thanks for the feedback and welcome to the forum.
 
Upvote 0
You're welcome. Thanks for the feedback and welcome to the forum.
I have a follow-up question. Not sure if something is wrong with my 2016 Excel or I am doing something wrong. The formula you provided works, but for some reason, Excel copies the same value to every cell (90% of all cells). I tried to apply the formula manually to some of the sheets and get the same outcome as when I created a macro to apply this to a large number of sheets. I don't think it's updating (Formulas are set to automatically calculate). In the Average column I have the formula you've provided and to the right the value it's supposed to be using average. I notice that by re-saving the file and clicking I don't want it to be an xlsm It corrects itself, but this doesn't work on my dataset probably because it's so large. Currently, Excel is Calculating (8 threads) 44% Any idea?

Book3.xlsx
ABCDEFGH
1DateTypeValueaverageactual average
21/1/2019A2.442.4966666672.496666667
31/1/2019A2.442.4966666672.496666667
41/1/2019A2.452.4966666672.496666667
51/1/2019A2.662.4966666672.496666667
61/1/2019A2.442.4966666672.496666667
71/1/2019A2.452.4966666672.496666667
81/1/2019A2.642.4966666672.496666667
91/1/2019A2.472.4966666672.496666667
101/1/2019A2.482.4966666672.496666667
111/1/2019B0.012.4966666670.06
121/1/2019B0.012.4966666670.06
131/1/2019B0.022.4966666670.06
141/1/2019B0.232.4966666670.06
151/1/2019B0.012.4966666670.06
161/1/2019B0.022.4966666670.06
171/1/2019B0.012.4966666670.06
181/1/2019B0.012.4966666670.06
191/1/2019B0.022.4966666670.06
201/1/2019B0.232.4966666670.06
211/1/2019B0.012.4966666670.06
221/1/2019B0.022.4966666670.06
231/1/2019B0.212.4966666670.06
241/1/2019B0.042.4966666670.06
251/1/2019B0.052.4966666670.06
261/1/2019C0.212.4966666670.1
271/1/2019C0.042.4966666670.1
281/1/2019C0.052.4966666670.1
291/2/2019A3.362.496666667
301/2/2019A3.362.496666667
311/2/2019A3.362.496666667
321/2/2019A3.52.496666667
331/2/2019A3.352.496666667
341/2/2019A3.362.496666667
351/2/2019A3.532.496666667
361/2/2019A3.352.496666667
371/2/2019B0.182.496666667
381/2/2019B0.052.496666667
391/2/2019B0.042.496666667
401/2/2019B0.052.496666667
411/2/2019B0.042.496666667
421/2/2019B0.042.496666667
431/2/2019B0.052.496666667
441/2/2019B5.72.496666667
451/2/2019C0.182.496666667
461/2/2019C0.052.496666667
471/2/2019C0.042.496666667
481/2/2019C0.052.496666667
491/2/2019C0.042.496666667
501/2/2019C0.042.496666667
511/2/2019C0.052.496666667
521/2/2019C5.72.496666667
531/3/2019A3.362.496666667
541/3/2019A3.352.496666667
551/3/2019A5.652.496666667
561/3/2019A5.662.496666667
571/3/2019A5.682.496666667
581/3/2019A5.682.496666667
591/3/2019A5.692.496666667
601/3/2019A3.942.496666667
611/3/2019A2.952.496666667
621/3/2019A0.022.496666667
631/3/2019A0.022.496666667
641/3/2019B3.942.496666667
651/3/2019B2.952.496666667
661/3/2019B0.022.496666667
671/3/2019B0.022.496666667
681/3/2019B0.022.496666667
691/3/2019B0.022.496666667
701/3/2019B3.362.496666667
711/3/2019C0.022.496666667
721/3/2019C0.022.496666667
731/3/2019C3.362.496666667
Sheet1
Cell Formulas
RangeFormula
H2:H10H2=AVERAGE(F2:F10)
H11:H25H11=AVERAGE($F$11:$F$25)
H26:H28H26=AVERAGE($F$26:$F$28)
G2:G73G2=AVERAGEIFS($F$2:$F$73,$B$2:$B$73,$B2,$C$2:$C$73,$C2)
 

Attachments

  • average.png
    average.png
    43.6 KB · Views: 6
Upvote 0
It turns out I had to leave excel in a non-responding state after clicking calculate sheet in order to update every cell (2 Million calculations) to its correct value. It only took 44+ hours to update the value and to save.
 
Upvote 0
You might try using a pivot table. It's not going to be practical to use that many formulas. I'm not sure if there is a limit on how much data a pivot table can handle, but probably worth a try.
Maybe someone else can help with a VBA solution.

1587943202495.png
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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