+ Reply to Thread
Results 1 to 15 of 15

sum distinct values given variable criteria

  1. #1
    Registered User
    Join Date
    05-20-2013
    Location
    louisiana
    MS-Off Ver
    Excel 2003
    Posts
    8

    sum distinct values given variable criteria

    Thanks for helping a new member.

    What I want to do is to sum the "current annual rev hrs" on the "RoleModules" worksheet for the roles entered under "Roles Assigned" on the "Totals" worksheet. I only included two roles to demonstrate the problem; however, there may be many dozens of role combinations that could be enterred.

    Because the same module may exist in multiple roles, I want to account for these module separately. Specifically, I want the sums of the "current annual rev hrs" for modules that are common to the roles assigned to show up in Totals cells B2 and C2, and I want the sums for the modules that are unique to a given role to show up in columns D and E for each role assigned.
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: sum distinct values given variable criteria

    Hi and welcome to the forum

    try using this...
    =SUMIF(A:A,"role1",O:O)
    or you could reference role1...
    =SUMIF(A:A,A2,O:O)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    05-20-2013
    Location
    louisiana
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: sum distinct values given variable criteria

    Thanks - but I do not see how that helps me differentiate between the modules that are unique to role1 (not also in role2).

  4. #4
    Registered User
    Join Date
    05-20-2013
    Location
    louisiana
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: sum distinct values given variable criteria

    OK, so I have given this some more thought. Suppose I have this data:

    ROLE MODULE TIME
    Role1 Mod1 1hr
    Role1 Mod2 1hr
    Role2 Mod1 1hr
    Role2 Mod3 1hr

    What I need to do is to calculate the total time for a person based on the roles assigned to that person. So, if a person is assigned role1 and role2, their total time would be 3 hrs, because they only need to do mod1 once. When I worked this manually to calculate the time by person, I filtered a list that included all roles and all modules assigned to each role by the role(s) assigned to that person, sorted the list by module, and then used the remove duplicates feature to remove any duplicate modules. The problem was that a new table had to be created for each combination of roles that each person might be assigned.

    So I guess what I am asking is whether there is some way use a formula replicate the function of the remove duplicates feature without having to generate new tables for each combination of roles?

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: sum distinct values given variable criteria

    add a samp[le of your expected outcome to your file please. Im not going to guess what you want

  6. #6
    Registered User
    Join Date
    05-20-2013
    Location
    louisiana
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: sum distinct values given variable criteria

    Sorry for that. I added the expected results in cell M4 and simplified the worksheet.
    Attached Files Attached Files

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: sum distinct values given variable criteria

    Thats pretty much exactly what my suggestion in post #2 did...

    =SUMIF($A:$A,role1,$J:$J) this will sum the hours for role1

    repeat this, and change to role2

  8. #8
    Registered User
    Join Date
    05-20-2013
    Location
    louisiana
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: sum distinct values given variable criteria

    I'm sorry, I must be really slow today, but I don't see how this gives me the total for someone who has both both role1 and role2 without double counting the modules that are in both role1 and role2. I get that those formulas will give me the totals for role1 and role2, if both those roles were not assigned to the same person:

    Sum HOURS Role 1 = 19.98
    Sum HOURS Role 2 = 25.58

    Combined this is 45.57.

    But what I need it to do is to subtract out/not count the 12.15 HOURS that are in both role1 and role2, which gives me the "Sum HOURS Assigned Role 1 and 2 = 33.42"

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: sum distinct values given variable criteria

    Yes, I see the role1 and role2 totals. How do you come up with the combined?

  10. #10
    Registered User
    Join Date
    05-20-2013
    Location
    louisiana
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: sum distinct values given variable criteria

    On a separate sheet, I removed duplicates and summed the total. Was just hoping I could get the answer without having to do that for different role combinations.

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: sum distinct values given variable criteria

    ok but what logic/rule are you using to do tat? I dint understand how you go from 19.98 band 25.58 to 33.42

  12. #12
    Registered User
    Join Date
    05-20-2013
    Location
    louisiana
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: sum distinct values given variable criteria

    Some modules are in both role1 and role2. I only want to count the hours of those modules one time. The 33.42 hours is the result of only summing the hours for each unique module one time. To perform that calculation manually using the attached spreadsheet, I use the remove duplicates feature to delete those rows where the same module is in both role1 and role2 and then sum the hours.

  13. #13
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: sum distinct values given variable criteria

    try:

    Please Login or Register  to view this content.
    Last edited by icestationzbra; 05-21-2013 at 09:22 PM.
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  14. #14
    Registered User
    Join Date
    05-20-2013
    Location
    louisiana
    MS-Off Ver
    Excel 2003
    Posts
    8

    Thumbs up Re: sum distinct values given variable criteria

    I'm very sorry for the late reply, but I have been out for the last couple of days. THANK YOU, that does it for me, thank you so much for your help. I truly appreciate it.

  15. #15
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: sum distinct values given variable criteria

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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