+ Reply to Thread
Results 1 to 12 of 12

averaging Vlookup

  1. #1
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    averaging Vlookup

    Attached is a workbook with a set of calendar days in column A, and another set of days in column F. Column F is missing some days, so I want to average the data in column B which does not have a corresponding date in column F.

    I've manually calculate a few of the cells in column F to show what I'm trying to achieve. I tried an "averageif "formula but couldn't get it to work.

    Thanks.
    Attached Files Attached Files

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: averaging Vlookup

    Hi jrtaylor,

    See if something like:
    Please Login or Register  to view this content.
    in M3 and pull down works for you.
    Average Indirect Match.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: averaging Vlookup

    Take M8 as an example. Why should the average be from B8 to B10, when B10 is PRESENT in column F?? Which is wrong? Your manually calculated result, or your description? What should it be?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: averaging Vlookup

    Hey Glenn,

    I'd bet they manually calculated M8 wrong. That is why they needed a formula.

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,814

    Re: averaging Vlookup

    I expect that AVERAGEIF() or AVERAGEIFS() will be at least part of the solution. I assume that you understand the basic "excel questions" like syntax and use of AVERAGEIFS() function. It seems to me that the question is more about the logic behind the function, which I could not back out of your example. I expect that, once the logic is understood, programming this into Excel (or any other programming language) will be easier.

    Your examples include --

    For 2 Jan, you are averaging the values for 1 and 2 January -- why not just pull the value for 2 Jan?
    For 3 Jan, you are pulling the value for 4 Jan -- why not pull the value for 3 Jan?
    For 9 Jan, you are averaging the values for 7, 8, 9 Jan.

    As a guess, something like =AVERAGEIFS($B$2:$B$32,$A$2:$A$32,">"&F3,$A$2:$A$32,"<="&F4) in M4 copied down might mostly work. It won't work for the first entry (M3), so you would need to come up with something a little different for the first entry. This function looks at the current rows date and the previous rows date and averages everything from column B where column A is "between" the previous row's date and the current row's date (between meaning greater than but not equal to previous row's date and less than or equal to current row's date). That is my best guess so far at what you intend to do.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: averaging Vlookup

    Thanks everyone. And as it often occurs, I made a mistake in the desired outcome calcs.

    A way to view this task is simply to think of the data in range F2:K24 as workdays. So if I get data on a Wed, there's no problem. I just match the data in the first range to the date in the second range.

    But if data streams in on Sat and Sun, I don't want to dismiss it. I can still use it by simply getting the average data for Sat, Sun and Mon. found in Column B, and plugging it into column M.

    So with that description, which formula above would be appropriate?

    And.. I apologize for my errors in the example workbook.

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,814

    Re: averaging Vlookup

    If I understand, my formula should do that. Did you try it? Did it give you what you expected? If not, which entries did it get wrong?

  8. #8
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: averaging Vlookup

    I tried to be more careful this time.

    I've manually calculated every row in column N, and then used the two suggested formulas in column M.

    I'm wondering if the two formulas are backwards... because the "Solution" column should refer to the actual working days (in column F), and not the days we collect the data.

    I appreciate your help here.
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,814

    Re: averaging Vlookup

    If you look more carefully at what I proposed, I proposed the averageifs between previous row's data and this row's date. The formula you put into column M is averageifs between this row's data and the next row's date. A slight and subtle difference, but enough to make the results one row off -- so my formula in M3 returns the same value as N4, M4 returns the same value as N5, and so on down the list (except for M13 and N14, and I don't understand why your desired outcome is pulling the value from 15 January when this row is for 17 January).

    If I assume that the value in N14 should be 19 (the value from B18 that corresponds to 17 Jan), then the current formula in column M (between this row and next row) seems correct -- except for one row off. If I use the formula I proposed in post #5 (previous row and this row -- so the formula starts in M4, not M3) the results match up with your desired results. Obviously, a different formula is needing in M3 [Maybe =AVERAGEIFS($B$2:$B$32,$A$2:$A$32,"<="&F3)]. Again, I am assuming that the current value in N14 (7.0) is incorrect and this one should be 19.0. If 7.0 is correct, then explain why this result is 7.0 (the value in B16).

  10. #10
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: averaging Vlookup

    Yes, I see what you mean. It is difficult for me to understand a formula unless I write it, so I did not analyze your solutions. But everything works. And yes, the value in N14 should be 19.

    I appreciate your help very much!

  11. #11
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: averaging Vlookup

    OH, PS. Will your formula work if the gap is more than 2 days? (e.g. holidays).

  12. #12
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,814

    Re: averaging Vlookup

    I think it should, assuming I have understood so far. The formula is averaging all of the values between the date in the previous row (but not including this date) and the date in the current row (including that date). So, if the previous row's date corresponds to last Thursday, and the current row's date corresponds to Tuesday, then it will average all of the days between (but not including) Thursday and Tuesday (including Tuesday). For that matter, if the previous row's date is the first of the previous month, and the current row's date is the first of the current month, it will average the entire month's data. The function really isn't trying to make any judgement or decision about how many days are included, it is only looking at "between" two dates. The only reason I can think of that this would not work is if there are scenarios where the desired average cannot be neatly described as "between" two dates.

+ 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. [SOLVED] Ignore errors when averaging multiple VLOOKUP's
    By tool_fairy in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 07-22-2016, 07:21 AM
  2. [SOLVED] Complex VLOOKUP of multiple records, adding results, and averaging them by record count
    By Aimee S. in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-10-2015, 10:12 AM
  3. [SOLVED] Averaging Specific VLookup Values
    By kujoking7 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 02-13-2015, 05:29 PM
  4. [SOLVED] using Vlookup with multiple results and averaging the results.
    By xatomicx in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-12-2015, 10:19 AM
  5. Complicated averaging-- averaging data that matches certain intervals
    By atung in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 10-22-2014, 04:19 PM
  6. Averaging help
    By cmorrison in forum Excel General
    Replies: 1
    Last Post: 08-17-2011, 03:23 PM
  7. averaging & ???
    By Dee/Daes in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-05-2006, 03:47 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