+ Reply to Thread
Results 1 to 14 of 14

SUM Matching Monthly Columns to Give a Variance

  1. #1
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    SUM Matching Monthly Columns to Give a Variance

    I have two sets of columns, the first M1 to M12 giving forecast figures, followed by an overall Total, then a second set giving M1 to M12 actuals (see attached). I need to be able to provide a variance in column AA for each row which is the difference between the Forecast YTD figure and the Actual YTD figure up to the current month. The current month will be defined by the column before the column where the sum of a column = 0, rather than by using the actual date.

    So it needs to check the sum of each column in the M1 to M12 actuals until it finds the first column that equals 0 (note it is possible for there to be zero values in cells within a column, i.e. a zero actual) and then SUM the actuals between M1 and the Month where the SUM of the column <>0, (M3 in the attached) and then subtract the equivalent YTD total for the same months in the M1 to M12 forecast to give the difference in column AA on a row by row basis.

    So in the example the first column in the M1 to M12 actuals to = 0 is column Q, so for each row it needs to SUM(N2:P2) - SUM(A2:C2) = -1,763

    Likewise if the total of column R >0 it would give te YTD variance for the first 4 months and so on.

    I've been playing around with OFFSET, MATCH and INDEX but still can't figure it out.

    Many thanks
    Attached Files Attached Files

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,913

    Re: SUM Matching Monthly Columns to Give a Variance

    a2=SUMPRODUCT((MMULT((COLUMN($A$1:INDEX($2:$2,ROWS($N$2:$N$20)))>0)*1,($N$2:$Y$20))>0)*($A2:$L2-$N2:$Y2))
    Please Login or Register  to view this content.
    try the above formula
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: SUM Matching Monthly Columns to Give a Variance

    I swapped the order in the last set of parenthesis because the variance needs to be 'actual' minus 'forecast' but either way, if I copy the formula down I get a #Value! error in rows, 5, 15 and 20!

    Please Login or Register  to view this content.

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,913

    Re: SUM Matching Monthly Columns to Give a Variance

    please rectify the following errors
    L5=90-
    L15=089-
    k20=0-

  5. #5
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: SUM Matching Monthly Columns to Give a Variance

    Whoops, hadn't spotted those... The position of my columns on my main sheet start in column AB rather than A and the sheets will conntinually have new rows added. Other than adjusting the N:Y and A:L references, would I need to adjust anything else for this to still work? I can't access the file at the moment!

  6. #6
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,913

    Re: SUM Matching Monthly Columns to Give a Variance

    You have to change
    $N$2:$N$20
    $N$2:$Y$20
    $N2:$Y2
    $A2:$L2

  7. #7
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: SUM Matching Monthly Columns to Give a Variance

    Okay, perfect, many thanks, I would never have figured this one out...

  8. #8
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: SUM Matching Monthly Columns to Give a Variance

    One further thought, Whilst this works well and provides a solution, I notice that if any of the cells are blank, the formula (by the nature of using MMULT) won't work. The data is going to be entered by the end users who have a habit of leaving cells blank rather than entering a zero when there is no value, so this could cause a problem. Are there any alternative solutions or ways to adapt this formula that would overcome this potential problem?

  9. #9
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,913

    Re: SUM Matching Monthly Columns to Give a Variance

    $N$2:$Y$20+0 use this instead of $N$2:$Y$20
    like as below
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: SUM Matching Monthly Columns to Give a Variance

    Okay, thanks, that seems to fix the problem...

    Many thanks

  11. #11
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,913

    Re: SUM Matching Monthly Columns to Give a Variance

    You are welcome, thanks for your feedback and adding reputation

  12. #12
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: SUM Matching Monthly Columns to Give a Variance

    Okay, so for the life of me I can not see the error. I've transposed the formula to my main sheet but I am getting #Value! as the result. Have I made an error here that I'm just not seeing?

    Please Login or Register  to view this content.
    Out of interest, what does the *1 part actually do?

  13. #13
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: SUM Matching Monthly Columns to Give a Variance

    Okay, figured it out, $A$1 has to remain as that...

  14. #14
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: SUM Matching Monthly Columns to Give a Variance

    nflsales,

    Is there an easy way to adapt your SUMPRODUCT formula to be able to display the variance as a percentage, the logic being:

    Please Login or Register  to view this content.
    so if $N2:$Y2 = 10 and $A2:$L2 = 20, then the variance would be -10 but as a percentage it would be ABS((10-20)/20) = 50% because you can't have negative variance.

    I've been struggling with how to do this and have so far failed to get it to work!

    Many thanks

+ 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. Need Excel formula that will give me a monthly average
    By mburke in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-20-2013, 09:23 AM
  2. [SOLVED] Calculating Variance Based on Matching Multiple Elements
    By bgauthier in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-22-2013, 06:05 PM
  3. Compare for matching names in Column A and calulate variance on a match
    By stashu117 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-19-2013, 11:02 AM
  4. Replies: 3
    Last Post: 10-12-2012, 01:55 AM
  5. Getting Pivot Table to give monthly Average
    By ChemistB in forum Excel General
    Replies: 6
    Last Post: 09-27-2010, 02:03 PM

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