Matching Column Data

albert_de

New Member
Joined
Mar 16, 2020
Messages
35
Office Version
  1. 2021
Platform
  1. Windows
I am currently building a Weather Station Data spreadsheet that will include Annual Maximums and Minimums from the Raw Data Download.
The Raw Data grows monthly, row by row, over the years. Therefore I need to be able to search the entire Raw Data array but only search for a specific period within that array.

I have uploaded a sample spreadsheet to Dropbox:
Dropbox

My problem:

In this Spreadsheet I know how to find the Minimum Temperature from the Downloaded Raw Data for a specific month or year.
e.g. from actual spreadsheet: =MINIFS('Raw Data'!$C:$C,'Raw Data'!$C:$C,"<>0",'Raw Data'!$A:$A,"2023*")

What I can’t work out is how to find the correct Matching Date for that Minimum.
This is because I don't know how to specify a year to search within the array.

I have tried INDEX MATCH without correctly working out how to do this for this task. I don’t know how to write a formula that searches within the array for a specific part/year.

Maybe XLOOKUp is the way to go? But again, I don’t know how to write a formula that searches for the lookup_value within a specific year in only part of the array.
E.g: =XLOOKUP(D3,'Raw Data'!B1:B22,'Raw Data'!A1:A22)

Also, I am not sure if XLOOKUP can look to the left by more than 1 Column (the actual Raw Data tab contains up to 34 Columns to the right of the Date Column)?

Notes:
  • The Date Column is TEXT format and not DATE Format. It will always be TEXT.
  • 0=no data sampled in data download. It does not normally mean 0 degrees. 0’s therefore need to be ignored.
  • It doesn’t matter if there are 2 or more identical values within a year.
Hoping that I have over thought this and that there is a simple answer! Thank you for your help.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Is this what you wanted?
Weather Data.xlsx
BCD
220222023
3TRUETRUE
4Annual Lowest Minimum19,716,8
5Date of Lowest Minimum2022-12-31 02:002023-01-02 02:00
Summary
Cell Formulas
RangeFormula
C3C3=COUNTIF('Raw Data'!A9:A23,"2022*")>0
D3D3=COUNTIF('Raw Data'!A9:A23,"2023*")>0
C4C4=IF(C3=FALSE,"",MINIFS('Raw Data'!B2:B23,'Raw Data'!B2:B23,"<>0",'Raw Data'!A2:A23,"2022*"))
D4D4=IF(D3=FALSE,"",MINIFS('Raw Data'!B2:B23,'Raw Data'!B2:B23,"<>0",'Raw Data'!A2:A23,"2023*"))
C5C5=IF(C3=FALSE,"",INDEX(TEXT('Raw Data'!A2:A23,"YYYY-MM-DD HH:MM"),MATCH(C4,'Raw Data'!B2:B23,0)))
D5D5=IF(D3=FALSE,"",INDEX(TEXT('Raw Data'!A2:A23,"YYYY-MM-DD HH:MM"),MATCH(D4,'Raw Data'!B2:B23,0)))
 
Upvote 0
another option for C5:
Excel Formula:
=IF(C3=FALSE,"",INDEX('Raw Data'!A2:A23,MATCH(C4,IF(YEAR('Raw Data'!A2:A23)=C2,'Raw Data'!B2:B23,0),0)))
or adopted to copying formulas from column C to right:
Weather Data (1).xlsx
ABCD
1
220222023
3TRUETRUE
4Annual Lowest Minimum19,716,8
5Date of Lowest Minimum2022-12-31 02:002023-01-02 02:00
Summary
Cell Formulas
RangeFormula
C3:D3C3=COUNTIF('Raw Data'!$A2:$A23,C2&"*")>0
C4:D4C4=IF(C3=FALSE,"",MINIFS('Raw Data'!$B2:$B23,'Raw Data'!$B2:$B23,"<>0",'Raw Data'!$A2:$A23,C2&"*"))
C5:D5C5=IF(C3=FALSE,"",INDEX('Raw Data'!$A2:$A23,MATCH(C4,IF(YEAR('Raw Data'!$A2:$A23)=C2,'Raw Data'!$B2:$B23,0),0)))


Final comments
- don't you have a chance for real 0 degrees as a minimum temperature?
- how about situation when there are several days with exactly the same minimum?
 
Upvote 0
Solution
Hi Sergius & Kaper.

Thank you both for your quick reply to my post. Both of your solutions work perfectly. Now I have to choose! Thank you very much for your expert guidance.

Kaper - It would be very rare if ever that we have a chance for real 0 degrees as a minimum temperature in Queensland, Australia. If we did, that would pose another problem for this spreadsheet!
I am not worried if there are several days with exactly the same minimum - as that is the minimum. The question is which date would be best to report, the earliest date or the latest date? For my purposes it probably doesn't matter.
 
Upvote 0
Glad we could help!

As for duplicating minimum dates (I introduced such example in raw data sheet):

1736504570804.png


If you could use Excel 365 just one formula (C3 and copied right) to do it all :-)
Weather Data (1).xlsx
ABCDEF
1
2202220232024
3Annual Lowest Minimum19,716,8no data
4Date(s) of Lowest Minimum2022-12-31 02:002023-01-02 02:00
52022-12-31 11:00
6
Summary
Cell Formulas
RangeFormula
C3:C5,E3,D3:D4C3=LET(dta,'Raw Data'!$A$2:$C$24,ydta,FILTER(dta,(YEAR(TAKE(dta,,1))=C2)*(INDEX(dta,,2)<>0)),ymin,MIN(INDEX(ydta,,2)),IFERROR(VSTACK(ymin,FILTER(TAKE(ydta,,1),INDEX(ydta,,2)=ymin)),"no data"))
Dynamic array formulas.


But with Excel 2021 TAKE and VSTACK are (as far as I know) not available, so "two-formulas" version (C3 and C4 copied right) shall (? I don't have 2021 so cannot test) do:
Weather Data (1).xlsx
ABCDEF
1
2202220232024
3Annual Lowest Minimum19,716,8no data
4Date(s) of Lowest Minimum2022-12-31 02:002023-01-02 02:00no data
52022-12-31 11:00
6
Summary (2)
Cell Formulas
RangeFormula
C3:E3C3=LET(dta,'Raw Data'!$A$2:$C$24,ydta,FILTER(dta,(YEAR(INDEX(dta,,1))=C2)*(INDEX(dta,,2)<>0)),IFERROR(MIN(INDEX(ydta,,2)),"no data"))
C4:C5,D4:E4C4=LET(dta,'Raw Data'!$A$2:$C$24,ydta,FILTER(dta,(YEAR(INDEX(dta,,1))=C2)*(INDEX(dta,,2)<>0)),ymin,MIN(INDEX(ydta,,2)),IFERROR(FILTER(INDEX(ydta,,1),INDEX(ydta,,2)=ymin),"no data"))
Dynamic array formulas.
 
Upvote 0
Thank you very much for that. I will have a good study of your formula.
Using the original formula suggestions, I am experiencing one incorrect match with both Temp and Date results. Spurious Temp and Year date are returned. It is very peculiar as the formula's are correct. And I can't replicate the issue anywhere else.
 
Upvote 0
As for possible source of problem:
I'd look whether all data in Raw Data sheet are the same format (it's about both A and B columns) - especially in row from which results are returned and these in row you expect to be returned.
 
Upvote 0
As best as I can tell the Raw Data has uniform formatting throughout.
I might rebuild the Raw Data etc. and see what happens!
 
Upvote 0
I have found what is happening with the non matching date.

The date INDEX MATCH formula is returning the first matching Temperature value from the entire column, that is from all Years. Not just the Year of the Temperature in question.

For example:

The formula being used to find the Lowest Temp for a specific year in the RAW Data is:

Records Tab, Cell H22:
=IF(Summary!H$6=FALSE,"",MINIFS('Raw Data'!$C:$C,'Raw Data'!$A:$A,"2025*"))

The formula being used to find the matching Date in the RAW Data is:

Records Tab, Cell H23:
=IF(H$22="","",INDEX(TEXT('Raw Data'!$A:$A,"YYYY-MM-DD HH:MM"),MATCH(H$22,'Raw Data'!$C:$C,0)))

There doesn't appear to be anything to Match the Year, there is only a Match to the Temperature (H$22). Can an additional Match criteria be added to the formula for the year?

This is what the RAW DATA table looks like:

1736593816882.png


Also on re making the Raw Data table I found that "-" is used when No Data is recorded, not "0". I must have manually changed the "-" in the past? I can't remember. But now "0" is a valid temperature in the spreadsheet!
 
Upvote 0
I'm sorry Kaper. You have already given me the answer in your post above:
=IF(C3=FALSE,"",INDEX('Raw Data'!A2:A23,MATCH(C4,IF(YEAR('Raw Data'!A2:A23)=C2,'Raw Data'!B2:B23,0),0)))

Or for the actual example in my last post:
=IF(Summary!H$6=FALSE,"",INDEX('Raw Data'!A:A,MATCH(H22,IF(YEAR('Raw Data'!A:A)=H21,'Raw Data'!C:C,0),0)))

This works perfectly :)

I am still to study your post on repeated Values. I am very keen to look at that.
 
Upvote 0

Forum statistics

Threads
1,225,477
Messages
6,185,212
Members
453,283
Latest member
Shortm88

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