How to find the maximum value in a column based on month and year?

LRATOZ

Board Regular
Joined
Aug 17, 2014
Messages
59
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have been collecting weather data for six years and I would like to make a dashboard that shows me the following:

The highest recorded temperature per month for each year.
(Similar as the record values in the climate table at Climate of Melbourne - Wikipedia)

My spreadsheet has got a column showing every dat over the last six years and has also a temperature reading for each date.

So, I want to find the highest temperature per month and per year with the date when it happened.
To find the maximum value per column is easy but I would like to see the maximum value for each month and on what date and in which year it happened.

Obviously, I record much more the just the temperature but once I know how to do this then it will be easy to apply the same formula to different data types.
So, if somebody has a solution this I would be grateful to hear about it.
Thank you very much in advance!
Luke
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
1. Please Update Your Account Details to We know which version of Excel you use to we help you based on.
At The Newer Version you can Use MAXIFS function.
2. Please Update example file with XL2BB ADDIN (Preferable) or upload at Free Hosting Site e.g. www.dropbox.com, GoogleDrive or .... and Insert Link Here.
 
Upvote 0
T202105a.xlsm
ABCDEFGHI
1DateTemperatureMax if
2StartEndMaxDate Max
31-Jan-21201-Jan-2131-Jan-2125253-Jan-21
43-Jan-2125Feb-2128-Feb-21242419-Feb-21
55-Jan-2123Mar-2128-Mar-2129296-Mar-21
62-Feb-2121Apr-2128-Apr-2132325-Apr-21
717-Feb-2122May-2128-May-21282818-May-21
819-Feb-2124
94-Mar-2123
106-Mar-2129For Year
1119-Mar-21241-Jan-2131-Dec-2132325-Apr-21
123-Apr-2125
135-Apr-2132
1418-Apr-2126
153-May-2127
1618-May-2128
175-May-2255
5a
Cell Formulas
RangeFormula
G3:G7G3=MAXIFS(Temp,Dates,">="&E3,Dates,"<="&EOMONTH(E3,0))
H11,H3:H7H3=MAXIFS(Temp,Dates,">="&E3,Dates,"<="&F3)
I3:I7I3=SUMPRODUCT(--(Dates>=E3),--(Dates<=F3),--(Temp=G3),Dates)
E4:F7E4=EDATE(E3,1)
A4:A5,A10,A13A4=+A3+2
A7,A12,A15:A16A7=A6+15
G11G11=MAXIFS(Temp,Dates,">="&E11,Dates,"<="&EOMONTH(E11-1,12))
I11I11=SUMPRODUCT(--(Dates>=E11),--(Dates<=F11),--(Temp=H11),Dates)
A9,A11,A14A9=A7+15
Named Ranges
NameRefers ToCells
Dates='5a'!$A$3:$A$17G11:I11, G3:I7, A4
Temp='5a'!$C$3:$C$17G11:I11, G3:I7
 
Upvote 0
T202105a.xlsm
ABCDEFGHI
1DateTemperatureMax if
2StartEndMaxDate Max
31-Jan-21201-Jan-2131-Jan-2125253-Jan-21
43-Jan-2125Feb-2128-Feb-21242419-Feb-21
55-Jan-2123Mar-2128-Mar-2129296-Mar-21
62-Feb-2121Apr-2128-Apr-2132325-Apr-21
717-Feb-2122May-2128-May-21282818-May-21
819-Feb-2124
94-Mar-2123
106-Mar-2129For Year
1119-Mar-21241-Jan-2131-Dec-2132325-Apr-21
123-Apr-2125
135-Apr-2132
1418-Apr-2126
153-May-2127
1618-May-2128
175-May-2255
5a
Cell Formulas
RangeFormula
G3:G7G3=MAXIFS(Temp,Dates,">="&E3,Dates,"<="&EOMONTH(E3,0))
H11,H3:H7H3=MAXIFS(Temp,Dates,">="&E3,Dates,"<="&F3)
I3:I7I3=SUMPRODUCT(--(Dates>=E3),--(Dates<=F3),--(Temp=G3),Dates)
E4:F7E4=EDATE(E3,1)
A4:A5,A10,A13A4=+A3+2
A7,A12,A15:A16A7=A6+15
G11G11=MAXIFS(Temp,Dates,">="&E11,Dates,"<="&EOMONTH(E11-1,12))
I11I11=SUMPRODUCT(--(Dates>=E11),--(Dates<=F11),--(Temp=H11),Dates)
A9,A11,A14A9=A7+15
Named Ranges
NameRefers ToCells
Dates='5a'!$A$3:$A$17G11:I11, G3:I7, A4
Temp='5a'!$C$3:$C$17G11:I11, G3:I7
Hi Dave,

Thank you very much for this!
Unfortunately, at the moment I'm overwhelmed with work commitments but will spend some time over the weekend.
I will definitly get back to you with feedback.
In the meantime thank you very much for your time and effort to help me out.
Much appreciated!
Luke
 
Upvote 0
Hi Dave,

I was able to find a couple of hours to go through your suggestions.
It took me a while but eventualy I was able to understand what you meant.
However, after three hours I got nowhere as the moment I press the enter button the cell showed #NAME?
I could't figure it out where I went wrong but then the penny dropped: I am using Excel 2016 and your code is for Excel 365.
Unfortunately the MAXIFS function is not included in the 2016 version.
I looked for possible code replacement and found a work-around by using something like this: MAX(IF(((A1:A10="value")*(C1:C10="value2"))>0, B1:B10))
Just when I understood your suggestinon it rendered useless for my version :)
I spent even more time trying to substitute the MAXIFS function with the suggestion as shown above, but unfrotunately I lack the knowledge to do so.
I followed the suggestion of Maabadi to update my profile so that next time everybody knows which version I use.
So, could you please replace your formula
=MAXIFS(Temp,Dates,">="&E3,Dates,"<="&EOMONTH(E3,0))
with a formula that works in Excel 2016?
My sincere apologies for not telling you which version I've got; I just didn't realize there was extra functionality in other versions.
Anyway, your suggestion is exactly what I'm looking for and I'm sure that this will be the solution to my problem.
Thank you very much for your help!
Cheers,
Luke
 
Upvote 0
1. Please Update Your Account Details to We know which version of Excel you use to we help you based on.
At The Newer Version you can Use MAXIFS function.
2. Please Update example file with XL2BB ADDIN (Preferable) or upload at Free Hosting Site e.g. www.dropbox.com, GoogleDrive or .... and Insert Link Here.
I've updated my profile Maabadi. Thanks for the suggestion!
 
Upvote 0
Good morning. It is 3:30 AM here. I may have better ideas later. You will have to determine what is appropriate for your database.
The helper columns can make the formula more manageable.

N.B. You can post my suggestion into a clean sheet; see the icon below the f(x) in the message header.

T202105a.xlsm
ABCDEFGHI
1DateMonthTemperatureMax Mo
2StartEndMonthMax TemperatureDate
31-Jan-21120251-Jan-2131-Jan-211253-Jan-21
43-Jan-2112525Feb-2128-Feb-2122419-Feb-21
55-Jan-2112325Mar-2128-Mar-213296-Mar-21
62-Feb-2122124Apr-2128-Apr-214325-Apr-21
717-Feb-2122224May-2128-May-2152818-May-21
819-Feb-2122424
94-Mar-2132329
106-Mar-2132929
1119-Mar-2132429
123-Apr-2142532
135-Apr-2143232
1418-Apr-2142632
153-May-2152728
1618-May-2152828
5aa
Cell Formulas
RangeFormula
H3:H7H3=LOOKUP(G3,$B$3:B$16,D$3:D$16)
I3:I7I3=SUMPRODUCT(--($B$3:$B$16=G3),--($C$3:$C$16=H3),$A$3:$A$16)
D3:D16D3=MAX(IF($B$3:$B$16=B3,$C$3:$C$16))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0
Good morning Dave,

Very impressive that you can work something out like that that early in the morning!
Over here it's nearly 8 PM and I will check it out tomorrow.
Anyway, my apologies to disturb your rest at night :-)
Cheers,

luke
 
Upvote 0
An alternative
T202105a.xlsm
ABCDE
1DateMonthTemperatureMax MoMax Date
2
31-Jan-21120253-Jan-21
43-Jan-21125253-Jan-21
55-Jan-21123253-Jan-21
62-Feb-212212419-Feb-21
717-Feb-212222419-Feb-21
819-Feb-212242419-Feb-21
94-Mar-21323296-Mar-21
106-Mar-21329296-Mar-21
1119-Mar-21324296-Mar-21
123-Apr-21425325-Apr-21
135-Apr-21432325-Apr-21
1418-Apr-21426325-Apr-21
153-May-215272818-May-21
1618-May-215282818-May-21
17
5aaa
Cell Formulas
RangeFormula
D3:D16D3=AGGREGATE(14,6,$C$3:$C$16/($B$3:$B$16=B3),1)
E3:E16E3=SUMPRODUCT(--($B$3:$B$16=B3),--($C$3:$C$16=D3),$A$3:$A$16)
 
Upvote 0
Since the data should not change, I would convert the helper column ranges to values.
I left the formulas in first data row Row 3.
The reporting would probably be on another Sheet.
The Index/Match is probably faster/more efficient that the earlier suggestion.

T202105a.xlsm
ABCDEFGHIJ
1DateMonthTemperatureMax MoMax DateMax if
2MonthMax °CDate
31-Jan-21120253-Jan-211Jan-21253-Jan-21
43-Jan-21125253-Jan-212Feb-212419-Feb-21
55-Jan-21123253-Jan-213Mar-21296-Mar-21
62-Feb-212212419-Feb-214Apr-21325-Apr-21
717-Feb-212222419-Feb-215May-212818-May-21
819-Feb-212242419-Feb-21
94-Mar-21323296-Mar-21
106-Mar-21329296-Mar-21
1119-Mar-21324296-Mar-21
123-Apr-21425325-Apr-21
135-Apr-21432325-Apr-21
1418-Apr-21426325-Apr-21
153-May-215272818-May-21
1618-May-215282818-May-21
17
5aaa
Cell Formulas
RangeFormula
B3B3=MONTH(A3)+(YEAR(A3)-YEAR($A$3))*12
D3D3=AGGREGATE(14,6,$C$3:$C$16/($B$3:$B$16=B3),1)
E3E3=SUMPRODUCT(--($B$3:$B$16=B3),--($C$3:$C$16=D3),$A$3:$A$16)
I3I3=INDEX($D$3:$D$16,MATCH(G3,$B$3:$B$16))
J3J3=INDEX($E$3:$E$16,MATCH(G3,$B$3:$B$16))
 
Upvote 0

Forum statistics

Threads
1,223,532
Messages
6,172,875
Members
452,486
Latest member
standw01

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