+ Reply to Thread
Results 1 to 16 of 16

Conditional Columns

  1. #1
    Registered User
    Join Date
    07-18-2012
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2007
    Posts
    6

    Conditional Columns

    I am looking for some help. I have 2 columns: 1 with a date, and 1 with a score. I am looking to show monthly averages automatically. Here is an example:
    Date Score Month Average
    20-Jan-12 91.6 January
    12-Jul-12 99.6 February
    23-Feb-12 88.8 March
    23-Feb-12 88.0 April
    23-Feb-12 92 May
    24-Feb-12 87.0 June
    17-May-12 98.0 July
    18-May-12 92.0 August
    19-May-12 90.0 September
    20-May-12 93.0 October
    27-Jan-12 99.2 November
    28-Jan-12 85.0 December
    29-Jan-12 77.0
    30-Jan-12 65.0
    1-Feb-12 98
    2-Feb-12 97.0
    4-Jan-12 98.8
    12-Dec-12 100.0

    Any suggestions?
    Thanks

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Conditional Columns

    You could use Pivot tables or with January in D2, in E2

    =SUMPRODUCT(--(TEXT($A$2:$A$19,"mmmm")=D2),$B$2:$B$19) dragged down
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Contributor BenMiller's Avatar
    Join Date
    12-06-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Conditional Columns

    Have you looked into the AVERAGEIF function?

  4. #4
    Registered User
    Join Date
    07-18-2012
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Conditional Columns

    AVERAGEIF always gives me an error!

    ---------- Post added at 02:29 PM ---------- Previous post was at 02:21 PM ----------

    That formula is showing a "zero"[COLOR="Silver"]

  5. #5
    Forum Contributor BenMiller's Avatar
    Join Date
    12-06-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Conditional Columns

    Quote Originally Posted by ChemistB View Post
    You could use Pivot tables or with January in D2, in E2

    =SUMPRODUCT(--(TEXT($A$2:$A$19,"mmmm")=D2),$B$2:$B$19) dragged down
    Does that work for you?
    That would give you the sum. To average it, try

    =SUMPRODUCT(--(TEXT($A$2:$A$19,"mmmm")=D2),$B$2:$B$19)/SUMPRODUCT(--(TEXT($A$2:$A$19,"mmmm")=D2))

  6. #6
    Registered User
    Join Date
    07-18-2012
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Conditional Columns

    Quote Originally Posted by BenMiller View Post
    That would give you the sum. To average it, try

    =SUMPRODUCT(--(TEXT($A$2:$A$19,"mmmm")=D2),$B$2:$B$19)/SUMPRODUCT(--(TEXT($A$2:$A$19,"mmmm")=D2))
    When I tried this, I got #DIV/O!

  7. #7
    Forum Contributor BenMiller's Avatar
    Join Date
    12-06-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Conditional Columns

    What do you have in D2?

  8. #8
    Registered User
    Join Date
    07-18-2012
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Conditional Columns

    Quote Originally Posted by BenMiller View Post
    What do you have in D2?
    "February" its a text cell

  9. #9
    Registered User
    Join Date
    07-18-2012
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Conditional Columns

    Monthly Average.xlsxHere is an example:

  10. #10
    Forum Contributor BenMiller's Avatar
    Join Date
    12-06-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Conditional Columns

    Can't open that, sorry I have 2003

  11. #11
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Conditional Columns

    Ahh, it's because you don't have February, you have Feb. This modification should work

    =IFERROR(SUMPRODUCT(--(TEXT($A$2:$A$19,"mmm")=D2),$B$2:$B$19)/SUMPRODUCT(--(TEXT($A$2:$A$19,"mmm")=D2)),"")

    changed from "mmmm" which expects the entire month to be written out to "mmm" which expect the 3 character abbreviation. Also I added the IFERROR part to keep out the errors when you don't have a month listed at all.

  12. #12
    Forum Contributor BenMiller's Avatar
    Join Date
    12-06-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Conditional Columns

    Thanks ChemistB! You are the bomb

  13. #13
    Registered User
    Join Date
    07-18-2012
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Conditional Columns

    Quote Originally Posted by ChemistB View Post
    Ahh, it's because you don't have February, you have Feb. This modification should work

    =IFERROR(SUMPRODUCT(--(TEXT($A$2:$A$19,"mmm")=D2),$B$2:$B$19)/SUMPRODUCT(--(TEXT($A$2:$A$19,"mmm")=D2)),"")

    changed from "mmmm" which expects the entire month to be written out to "mmm" which expect the 3 character abbreviation. Also I added the IFERROR part to keep out the errors when you don't have a month listed at all.
    That worked, however, this was a sample and the rather large document I am working on has some blank cells (not yet entered). The formula is calculating these blank cells as "zeros" and lowering the actual average. I am in over my head!

  14. #14
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Conditional Columns

    This looks in column B and only counts it if it's > 0

    =IFERROR(SUMPRODUCT(--(TEXT($A$2:$A$19,"mmm")=D2),--($B$2:$B$19>0),$B$2:$B$19)/SUMPRODUCT(--(TEXT($A$2:$A$19,"mmm")=D2),--($B$2:$B$19>0)),"")

  15. #15
    Forum Contributor BenMiller's Avatar
    Join Date
    12-06-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: Conditional Columns

    Blank cells ... meaning they have a date in column A but no number in column B?

  16. #16
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Conditional Columns

    How about

    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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