+ Reply to Thread
Results 1 to 16 of 16

sumif with 2 variables

  1. #1
    Registered User
    Join Date
    09-25-2008
    Location
    Granada
    Posts
    7

    sumif with 2 variables

    I got the following problem:

    In a spreadsheet each line is a payment, columns include various information. I want to include a formula that gives me the sum of all payments from each month and for a specific classification code (12 in total).
    For example the sum of all payments with classification code "b" from January.

    Any ideas how to solve this issue?
    I cannot get my head around this...

    Thx for the help!

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Hi and welcome to the board
    do a search on this forum on SUMPRODUCT
    More info on this function

  3. #3
    Forum Contributor
    Join Date
    09-23-2008
    Location
    UK
    Posts
    137
    Create a column which is the concatenation of the month and clasification code, then use this as your range.

    eg.
    A B C D Z
    month class code payment jana
    jan a jana 100
    feb b febb 120
    mar b marb 108

    sumif(C:C=Z1,D:D)

    To concatenate use C2=TEXT(A2,"mmm")&B2 for example.

    Martin

    I got the following problem:

    In a spreadsheet each line is a payment, columns include various information. I want to include a formula that gives me the sum of all payments from each month and for a specific classification code (12 in total).
    For example the sum of all payments with classification code "b" from January.

    Any ideas how to solve this issue?
    I cannot get my head around this...

    Thx for the help!
    Last edited by arthurbr; 09-25-2008 at 09:32 AM.

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Using a Pivot Table is also a possibility

  5. #5
    Registered User
    Join Date
    09-25-2008
    Location
    Granada
    Posts
    7
    Thx for the replies!
    Tried the concatenation table and think that could work... The only problem left is that the date is entered as a number not as text. If I make a new table to concatenate date+classification there is no relation anymore to payments.

    Thx again!!!

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Here's an example where I created a table using the SUMPRODUCT function. Let us know if this works for you.
    Please Login or Register  to view this content.
    where your dates are in columnA, Code in B and payment in C. Your referenced month number is in E and your referenced code is in row 2 beginning with F.
    Attached Files Attached Files
    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

  7. #7
    Forum Contributor
    Join Date
    12-06-2005
    Posts
    118
    A sum with 2 if statements and then ctrl-shift-enter will also work. Let me know if the above options don't work.

  8. #8
    Registered User
    Join Date
    09-25-2008
    Location
    Granada
    Posts
    7
    still got the problem to define my date column as criteria...
    dates are shown as "jan, feb, mar..." but the criteria canīt be "jan" as the data is no text in the original field.

    Thx again!

  9. #9
    Registered User
    Join Date
    09-25-2008
    Location
    Granada
    Posts
    7
    I attached the formula thats not working currently...

    =SUMPRODUCT(--MONTH([SXSL.xls]Pagos!$G$576:$G$2500)=$C16)*([SXSL.xls]Pagos!$C$576:$C$2500=B18)*([SXSLxls]Pagos!$H$576:$H$2500)

    First parameter contains dates, 2nd classification and the 3rd the payments

    Can it be an issue that I use data from another worksheet?

    Thx!

  10. #10
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    What error do you get ?
    Can you post a small sample ?

  11. #11
    Registered User
    Join Date
    09-25-2008
    Location
    Granada
    Posts
    7
    "a value used in the formula is of the wrong data type"
    guess its the date values that dont function...

  12. #12
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    A small sample of your data really would help....

  13. #13
    Registered User
    Join Date
    09-25-2008
    Location
    Granada
    Posts
    7
    Ok, the analysis worksheet got the formula in C4.
    At least I get a result by now although its a false one...

    Thx!!!
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    I adapted the underlying data from row2 on the Analysis sheet and the formula ( absolute and relative ref)
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    09-25-2008
    Location
    Granada
    Posts
    7
    Thx arthurbr,

    Works on the sample sheet but not on the original data...
    Error: "a value is not available to the formula or function" appears.

    Guess there has to be a mistake on the data side or? any other ideas?

    Thx again!

  16. #16
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Well, without seeing your data, my only way of helping is a crystal ball...

+ 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. Clear Public Variables Only?
    By rziegler in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-17-2008, 01:05 PM
  2. Using Variables from Modules in Userforms
    By googlebot in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-09-2008, 02:57 PM
  3. User-defined variables in MS access query
    By ratzy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-11-2007, 11:13 AM
  4. SUMIF for multiple variables
    By Kjaer in forum Excel General
    Replies: 3
    Last Post: 08-13-2007, 11:56 AM
  5. Variables in macros?
    By Nymphadora in forum Excel - New Users/Basics
    Replies: 13
    Last Post: 12-01-2006, 04:02 AM

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