+ Reply to Thread
Results 1 to 21 of 21

Match record number across sheets based on data from multiple columns

  1. #1
    Registered User
    Join Date
    08-08-2013
    Location
    Walla Walla
    MS-Off Ver
    Excel 2003
    Posts
    11

    Match record number across sheets based on data from multiple columns

    I am working on a database that will hold data collected from surveys of beaver dams. I have data that is singular for each dam (i.e. dam length, pond depth), double for each dam (i.e. vegetation from river right and river left), and data that is multiple for each dam (i.e. waypoints taken across the length of the dam).

    I currently have the single, double and multiple data types in different sheets ('dam assessment', 'habitat assessment', 'waypoint data') that have corresponding event data but I would like to find a way to reference each dam to each other using a record number.

    In my view, each dam in the 'dam assessment' sheet would have a record number that would then be used across the 'habitat assessment' and 'waypoint data' sheets. I would like this to happen automatically by using some formula in the record number column in 'habitat assessment' and 'waypoint data' that references data in the 'dam assessment' sheet. In 'dam assessment' there are two columns that give a waypoint start and waypoint end for each dam and in 'waypoint data' the waypoints are listed.

    Ultimately, this data will be used in ArcGIS to map the beaver dams with the dam assessment and habitat data in the attribute table so there needs to be at least one value that is consistent across sheets for each beaver dam in the database.

    I'll attach an example spreadsheet that shows what kind of data and format I'm dealing with.

    Thank you for your help. I apologize if anything in my request is unclear but I'm still working on my excel vocabulary. Please let me know if there's anything I could clear up that would help solve the problem.
    Attached Files Attached Files

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Match record number across sheets based on data from multiple columns

    I think the most efficient way to capture the data would be to use a combination of index and matches. The functions will find a record number on Dam, find a variable column on Dam, and report back the contents on whatever tab you want.

    I'm currently having difficulty navigating your sample because of its formatting; what columns letters specifically on Habitat and Waypoint are you trying to fill in with data from Dam?
    Last edited by daffodil11; 08-08-2013 at 01:54 PM.

  3. #3
    Registered User
    Join Date
    08-08-2013
    Location
    Walla Walla
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Match record number across sheets based on data from multiple columns

    Hi daffodil11, thanks for answering my call for help.

    I am trying to fill in column A (Record number) on 'habitat assessment' and 'waypoint data' with the record number that matches from column A in 'dam assessment. I think that using the Date (column B) and Site (column C) along with the dam number (M in 'dam assessment' and 'habitat assessment) would work for filling the record number in the 'habitat assessment' sheet.

    In the waypoint data sheet, I would need to use the data in AF and AG of 'dam assessment' to match with K of 'waypoint data.'

    Hope this helps. Thanks again!

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Match record number across sheets based on data from multiple columns

    Habitat Assessment, A8 =

    =SUMPRODUCT(('Dam assessment'!$B$11:$B$1474='Habitat Assessment'!B8)*('Dam assessment'!$C$11:$C$1474='Habitat Assessment'!C8)*('Dam assessment'!$M$11:$M$1474='Habitat Assessment'!K8)*('Dam assessment'!$A$11:$A$1474))

    Drag down as needed
    Last edited by daffodil11; 08-08-2013 at 03:40 PM. Reason: formula code removed, long formula

  5. #5
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Match record number across sheets based on data from multiple columns

    Waypoint Data, A9=

    =SUMPRODUCT(('Dam assessment'!$AF$11:$AF$1474='Waypoint data'!K9)*('Dam assessment'!$A$11:$A$1474))+SUMPRODUCT(('Dam assessment'!$AG$11:$AG$1474='Waypoint data'!K9)*('Dam assessment'!$A$11:$A$1474))

    and copy down as needed

    Note: a lot of the points listed on Waypoint Data do not seem to correspond to Dam Assessment records.

  6. #6
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Match record number across sheets based on data from multiple columns

    Dam Beavers.xlsx

    Here's my finished result.

  7. #7
    Registered User
    Join Date
    08-08-2013
    Location
    Walla Walla
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Match record number across sheets based on data from multiple columns

    I tried the formula but received an error message saying that the formula refers to empty cells. I asked it to trace and it gave me this:

    Screen Shot 2013-08-08 at 1.44.18 PM.png

    My formula bar looks like this

    Screen Shot 2013-08-08 at 1.48.41 PM.png

    If you have the time could you explain how your formula works?

  8. #8
    Registered User
    Join Date
    08-08-2013
    Location
    Walla Walla
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Match record number across sheets based on data from multiple columns

    Oops,

    Nevermind that last post. I was putting things into a mockup I had made a couple days ago. I'd still be interested in hearing what your thought process was on the problem.

  9. #9
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Match record number across sheets based on data from multiple columns

    I'm not so sure, but I can break down the formula logic so you can reverse engineer it and apply it to other scenarios in the future:

    SumProduct adds up the sums of multiple arrays, so that {1,2,3} * {4,5,6} = (1*4) + (2*5) + (3*6) = 28

    When applied to nonnumerical arrays with an operator, it matches them for the criteria specified, so that {bob,tom,frank=bob}*{1,2,3} = for every bob in {bob,tom,frank}, it multiplies the values out against the other array and then adds them together. This is extra useful for arrays where the criteria occurs more than once:

    sumproduct((bob,frank, tom, bob, bob, tom=bob)*(1,2,3,4,5,6)) = 1 + 4 + 5 = 10

    Applied to your situation:
    =SUMPRODUCT(('Dam assessment'!$B$11:$B$1474='Habitat Assessment'!B8)*('Dam assessment'!$C$11:$C$1474='Habitat Assessment'!C8)*('Dam assessment'!$M$11:$M$1474='Habitat Assessment'!K8)*('Dam assessment'!$A$11:$A$1474))

    is doing:

    =SUMPRODUCT((All Locations=Habitat Assessment Location in B8)*(All Dates=Habitat Assessment Date in C8)*(All Dam #s='Habitat Assessment Dam # in K8)*(All Records))

    It finds about 10 matching locations, of those find about only 4 matching dates, of those finds only one matching dam #, and multiplies that the matching record, which there is only one, and adds them up, still getting just that one.



    The waypoint SumProduct is working the same way, its just doing it twice, once for each waypoint with an output that will always be "a record # + 0" or "0 + a record #"

  10. #10
    Registered User
    Join Date
    08-08-2013
    Location
    Walla Walla
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Match record number across sheets based on data from multiple columns

    Genius. Thank you so much for your help.

  11. #11
    Registered User
    Join Date
    08-08-2013
    Location
    Walla Walla
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Match record number across sheets based on data from multiple columns

    Ok,

    So, some more problems on my end. The formula works correctly in your file but when I copy and paste the formula into my original database it gives me there error that the formula refers to empty cells and returns the value 0.
    Screen Shot 2013-08-12 at 9.44.06 AM.jpg

    I understand that the reason for the empty cells error (the array comes down to row 1474 so that new data can be added without the formula screwing up) but I don't understand why the return value is 0 in my database but it works in Dam Beavers.xlsx. I've checked and it's definitely the same formula.

    Also: The formula for the Waypoints sheet doesn't seem to be functioning quite correctly. The first 7 rows should have a record number of 00001 because they refer to the waypoints across the first dam in 'Dam assessment.' The next 5 would have the record number 00002. In an ideal world it would look something like this: Screen Shot 2013-08-12 at 9.59.46 AM.jpg

    I really appreciate your help in working through these kinks. You are a wizard.

  12. #12
    Registered User
    Join Date
    08-08-2013
    Location
    Walla Walla
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Match record number across sheets based on data from multiple columns

    Ok, I've solved the first problem but the problem with the waypoint sheet still exists

  13. #13
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Match record number across sheets based on data from multiple columns

    What is the actual result you are getting?

  14. #14
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Match record number across sheets based on data from multiple columns

    My results look fine to me.

    Waypoint 132 matches record 80 on the first tab.

    Waypoint 133 matchds record 81 on the first tab.

    Waypoints 134, 135, 136 do not correspond to any records on tab 1.



    Are you trying to get records that fall between the waypoint locations?


    Give this a try instead:
    =SUMPRODUCT(('Dam assessment'!$AF$11:$AF$1474>='Waypoint data'!K9)*('Dam assessment'!$AG$11:$AG$1474<='Waypoint data'!K9)*('Dam assessment'!$A$11:$A$1474))

    The big issue you run into with this however, is that record 80 and 81 for example contain waypoints within record 1.
    Last edited by daffodil11; 08-12-2013 at 12:27 PM.

  15. #15
    Registered User
    Join Date
    08-08-2013
    Location
    Walla Walla
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Match record number across sheets based on data from multiple columns

    Here's what it looks like on my end: Screen Shot 2013-08-12 at 10.23.05 AM.jpg

    Multiple waypoints apply to each dam. So, for instance, Record 1 has the waypoints 131 through 137 inclusive for the Site name 'North Creek' and Date '20130718' which I probably didn't express clearly. So that's why the first 7 rows of the waypoints tab should all be 00001. This may complicate things significantly. I'm not sure.

    Thanks for getting back to me so quickly.

  16. #16
    Registered User
    Join Date
    08-08-2013
    Location
    Walla Walla
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Match record number across sheets based on data from multiple columns

    Though waypoints might have the same number, if they come from different survey events, they will correspond to a different lattitude and longitude.

    Your formula seems to be getting closer to the right thing. This is what the database looks like now: Screen Shot 2013-08-12 at 11.27.52 AM.jpg

    Note: I added a couple columns for 'Datum' and 'Zone' so I changed K9 to M9

  17. #17
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Match record number across sheets based on data from multiple columns

    Okay, I found the source of one of the issues.

    Records 1, & 2 all share the same location, same date, and overlapping Waypoints.

    1 has waypoints 131-137

    2 has waypoints 137-142

    Which record does Waypoint 137 belong to?

    Do the records have any other unique identifiers?

  18. #18
    Registered User
    Join Date
    08-08-2013
    Location
    Walla Walla
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Match record number across sheets based on data from multiple columns

    137 belongs to record 1, my mistake. Thanks for catching it.

    The records don't have any other unique identifiers besides date, site name, and surveyor. It seems like that should be enough. There shouldn't be multiple waypoints that refer to the same dam unless there's a mistake on the part of the surveyor.

  19. #19
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Match record number across sheets based on data from multiple columns

    Ok, found the last issue. Records with only 1 waypoint associated with them need to have start and end listed as the same number.

    Blank Cells register a value of zero, so that cell was being picked up within all the ranges.

    Original formula seems to still work.


    (I modified the K to M)
    =SUMPRODUCT(('Dam assessment'!$B$11:$B$1474='Waypoint data'!B9)*('Dam assessment'!$C$11:$C$1474='Waypoint data'!C9)*('Dam assessment'!$AF$11:$AF$1474<='Waypoint data'!M9)*('Dam assessment'!$AG$11:$AG$1474>='Waypoint data'!M9)*('Dam assessment'!$A$11:$A$1474))

  20. #20
    Registered User
    Join Date
    08-08-2013
    Location
    Walla Walla
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Match record number across sheets based on data from multiple columns

    This is awesome. Just awesome. I wish I could bake you cookies or something for all the help you've given me.

  21. #21
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Match record number across sheets based on data from multiple columns

    Haha, it was a pleasant diversion from my work. Thanks for the feedback.

    I ask almost as many questions as I answer, so feel to drop by again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 14
    Last Post: 10-07-2013, 04:04 PM
  2. Combine information from multiple works sheets based on a cell and data in columns
    By Rick_HpyVly in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-19-2013, 02:49 PM
  3. Replies: 0
    Last Post: 10-16-2012, 03:26 PM
  4. Replies: 2
    Last Post: 06-29-2011, 01:36 PM
  5. Replies: 3
    Last Post: 12-08-2005, 06:00 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1