+ Reply to Thread
Results 1 to 5 of 5

Need to calculate average over a date range using several variables

  1. #1
    Registered User
    Join Date
    01-16-2014
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    25

    Need to calculate average over a date range using several variables

    Good evening Excel-ent people!

    Can anyone help with this problem? I have a workbook where you can set a variable date range via a 'From Date' cell and a 'To Date' cell. There are then 3x separate tables within (although these aren't actually formatted as tables within Excel). There are a list of employees and targets for each employee within one table. In another table is a set of positions (job roles) for each employee, including the date of any change in position (i.e. a promotion). There is then a final table containing what should be the targets for each position (however there are several columns as these targets can change across the board on a particular date).

    It has been set up that there can be up to 3x position changes per employee, and up to 4x wholesale changes to all Targets per position. There are date fields for both the change in Position (in an adjacent column), and also within the Targets table (above each column).

    What I would like is a formula to enter into the Targets column of the first table, which calculates the average target over the specified date range. This would need to look at the date range, consider what the target should be at the start of that range, then any changes and when, and calculate an average over that period.

    It seems like this should be perfectly possible, although given there are a number of variables here, I can't wrap my head around this.

    I had thought that maybe this might require a number of helper columns, but even that I couldn't figure out. And given the actual data set has up to 8x position changes and 10x wholesale changes, I figure that this would require quite a lot of helper columns (so if that can be avoided great - if not, then fine).

    Not sure if it complicates things further; however if this were able to look at week days only (i.e. incorporate the NETWORKDAYS function), that would be great.

    The Workbook can be found attached. If anyone has any bright ideas, then I'm all ears!

    Dummy Report.xlsx

    I have calculated manually what these figures should be for cross-checking purposes. Allowing for week days only, the target that I have calculated over the date range as currently populated (rounded to 2x decimal places) are as follows:

    Richie - 2.13
    Palmer - 5.53
    Marshall - 3.87
    Milligan - 3.87

    Thanking you in advance!

    Skins
    Last edited by Skins11; 08-19-2023 at 06:06 PM.

  2. #2
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,435

    Re: Need to calculate average over a date range using several variables

    One way: Plaese try in B5 and copy down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,435

    Re: Need to calculate average over a date range using several variables

    Or the whole column B in one go, please empty all cells in B5:B8 and try in B5 (no copy down needed):
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-16-2014
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    25

    Re: Need to calculate average over a date range using several variables

    Wow, Hans - you're a wizard! Thanks for taking the time to look at this and to comment.

    It took me a little bit of time to figure out what was doing what in the formula, but I think I largely understand it now (every day's a school day)!

    I needed to make a couple of changes here, to get this to work exactly how I needed it to.

    Firstly, it seemed set up to look at whole months rather than individual dates, and therefore if the date range started or ended halfway through a month, this would not be picked up by the formula.

    Secondly, I needed this set up to lookup the Names in the Positions table rather than be fixed to the same row (as these may not necessarily correlate with the same row number).

    Finally, this was set up to look at all of the dates within the date range, not just the weekdays (i.e. ignoring any weekend dates).

    I have therefore made a few amendments which now seem to allow for all of the above. I definitely wouldn't have been able to do this without your initial insight however, so again, thank you.

    Revised code and workbook below:

    Please Login or Register  to view this content.
    Dummy Report v2.xlsx


    Cheers

    Skins

  5. #5
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,435

    Re: Need to calculate average over a date range using several variables

    You are Welcome!

    Thanks for the feedback and rep .

    Glad to hear that you can adjust the formula to your own wishes.
    You learn the most from that. .

+ 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] Getting an average value from a range, with 3 variables
    By Caibo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-16-2023, 04:49 AM
  2. [SOLVED] calculate time remaining with 3 date variables
    By megs2113 in forum Excel General
    Replies: 2
    Last Post: 01-03-2020, 07:09 PM
  3. Calculate Weighted Average within a date range
    By danallamas in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-27-2016, 10:59 AM
  4. Replies: 1
    Last Post: 03-13-2013, 02:27 PM
  5. [SOLVED] Average of Range - While Accounting for Variables
    By StevenBleich in forum Excel General
    Replies: 6
    Last Post: 06-01-2012, 02:31 PM
  6. Using variables to determine a range for an average.
    By blastronaut in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-08-2011, 05:58 PM
  7. Calculate Average Using Date Range
    By LisaG in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-02-2008, 11:39 AM

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