+ Reply to Thread
Results 1 to 15 of 15

Summing based on several conditions

Hybrid View

  1. #1
    aiwnjoo
    Guest

    Summing based on several conditions

    I have used various formulas but cannot get it right its annoying me now;

    Tried:

    =SUM(IF($D$2:$D$202=$T$10,Task_Timings!$B$10+SUM(IF($D$2:$D$202=$T$10,IF($H$2:$H$202="Yes",Task_Timings!$C$10)))))

    Tried:

    =SUM(IF($D$2:$D$202=$T$10,Task_Timings!$B$10),SUM(IF($H$2:$H$202="Yes",Task_Timings!$C$10)))

    Seems to just calculate random figures and sum everything up wrongly.

    What it should do is;

    IF D2:D202 contains whatevers in T10 AND H2:H202 contains the word "Yes" it will then add together Task_Timings B10 and C10. But IF H2:H202 contains nothing then it should just give the Task_Timing B10 value.

    Thanks,
    Last edited by NBVC; 08-05-2010 at 09:38 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUM(IF (Summing wrong)

    so all of D2:D202 must contain the T10 value and all of H2:H202 must contain a "yes" for the 2 cells to be added together? Is that the requirement?
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    aiwnjoo
    Guest

    Re: SUM(IF (Summing wrong)

    Yes thats right i would rep you but i repped you last lol so it wont let me until someone else helps.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUM(IF (Summing wrong)

    Well, I guess I shouldn't try to help then...sorry...

    .. just kidding.... no worries about the rep....

    Does this work for you?

    =SUM(IF(AND(COUNTIF($D$2:$D$202,"<>"&$T$10)=0,COUNTIF($H$2:$H$202,"<>Yes")=0),Task_Timings!$B$10:$C$10),Task_Timings!$B$10)

  5. #5
    aiwnjoo
    Guest

    Re: SUM(IF (Summing wrong)

    Afraid not but close;

    T10 points to a word called DIAL

    D2:D202 contains a validation list with this word in there.

    H2:H202 contains a validation list of Yes or No

    Task_Timings B10 gives a time for DIAL of 0:1:22 and in C10 gives an addition 0:8:00

    If i enter DIAL anywhere in D and i put a Yes in H on the same row it should give back 0:9:22, if i put a No then it should just give the default time of 0:1:22.

    But the formula should work as i exampled and so did you that it needs to use arguments so that it does not end up counting up incorrect times.

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUM(IF (Summing wrong)

    So then not all of column D has to be equal to T10 and not all of column H needs to equal Yes,

    How about?

    =IF(SUMPRODUCT(--($D$2:$D$202=$T$10),--($H$2:$H$202="Yes")),SUM(Task_Timings!$B$10:$C$10),IF(COUNTIF($D$2:$D$202,$T$10),Task_Timings!$B$10,""))

  7. #7
    aiwnjoo
    Guest

    Re: SUM(IF (Summing wrong)

    This works but only counts one instance of it, so if lets say in D2 I put DIAL and in H2 I put Yes it will give me the right time, but if I then put DIAL in H3 it will not add on any time.

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUM(IF (Summing wrong)

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

  9. #9
    aiwnjoo
    Guest

    Re: Summing based on several conditions

    Here you go it will make sense.
    Attached Files Attached Files

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing based on several conditions

    Ok, how about?

    =IF(COUNTIF($D$2:$D$202,$T10),SUMIF(Task_Timings!$A:$A,$T10,Task_Timings!$B:$B),0)+SUMPRODUCT(--($D$2:$D$202=$T10),--($H$2:$H$202="yes"))*SUMIF(Task_Timings!$A:$A,$T10,Task_Timings!$C:$C)


    In U2, it would be:
    =IF(COUNTIF($D$2:$D$202,$T2),SUMIF(Task_Timings!$A:$A,$T2,Task_Timings!$B:$B),0)+SUMPRODUCT(--($D$2:$D$202=$T2),--($H$2:$H$202="yes"))*SUMIF(Task_Timings!$A:$A,$T2,Task_Timings!$C:$C)
    copied down.

  11. #11
    aiwnjoo
    Guest

    Re: Summing based on several conditions

    Thanks, looks good but;

    If T2 = CALL IN it will produce 0:9:42, but if in D2 and D3 i put CALL IN it should calculate to 0:19:24 in O1 and in the table U2.

    Thanks for the help.

  12. #12
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing based on several conditions

    I am not sure I understand you...

    I thought you wanted to account for the main time once and then add the added time for each further occurance of the combination of what is in T2 and "Yes"?

    Your logic seems to be changing...

  13. #13
    aiwnjoo
    Guest

    Re: Summing based on several conditions

    No,

    You see in Task_Timings, only certain tasks have an additional timing which would rely on the Yes.

    CALL IN for example has only one timing, so if in D2 and D3 i put CALL IN it should just give 2 * its correct timing and so on.

    If for example we select DIAL then there are two timings, if say in D2 and D3 i put DIAL and in H2 i put Yes and H3 i leave blank then it should give me 0:10:38.

    Sorry if i confused you.

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing based on several conditions

    Is this it?

    =COUNTIF($D$2:$D$202,T2)*SUMIF(Task_Timings!A:A,T2,Task_Timings!B:B)+SUMPRODUCT(--($D$2:$D$202=T2),--($H$2:$H$202="yes"))*SUMIF(Task_Timings!A:A,T2,Task_Timings!C:C)
    in U2, copied down.

  15. #15
    aiwnjoo
    Guest

    Re: Summing based on several conditions

    Ohhh riiiite, thanks.

+ 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