+ Reply to Thread
Results 1 to 7 of 7

sumifs (or sumproduct) but with division - and a lookup

  1. #1
    Registered User
    Join Date
    02-14-2014
    Location
    Alexandria, VA
    MS-Off Ver
    Excel 2010
    Posts
    8

    sumifs (or sumproduct) but with division - and a lookup

    I need to calculate the total # of hours worked on an individual project and project type.

    Column A contains employee name, column B contains project name, column C contains project type, and column D contains total cost. Elsewhere on this worksheet is a (lookup) table (F2:G4) that contains a unique list of employee names (column F) and their hourly rate (column G).

    I want to calculate total hours worked on a specific project of a specific type (multiple criteria). My first approach was to use sumifs to calculate total cost, then divide this value by the employees hourly rate. I tried this to calculate the total cost: =SUMIFS(D2:D7, B2:B7, "A", C2:C7, "ZZ")

    This worked great, but the next step is where I encountered a problem. To calculate the total hours I have to first divide the cost by the employee's hourly rate before summing them. Maybe I have to use a sumproduct division technique, but I couldn't get it to work. How can I calculate total hours worked by project (and project type)?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,426

    Re: sumifs (or sumproduct) but with division - and a lookup

    Please post a sample workbook indicating your expected results.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: sumifs (or sumproduct) but with division - and a lookup

    Try using SUMPRODUCT for total hours with a SUMIF included which divides by the hourly rate, i.e.

    =SUMPRODUCT((B2:B7= "A")*(C2:C7= "ZZ"),D2:D7/SUMIF(F2:F4,A2:A7,G2:G4))
    Audere est facere

  4. #4
    Registered User
    Join Date
    02-14-2014
    Location
    Alexandria, VA
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: sumifs (or sumproduct) but with division - and a lookup

    Quote Originally Posted by daddylonglegs View Post
    Try using SUMPRODUCT for total hours with a SUMIF included which divides by the hourly rate, i.e.

    =SUMPRODUCT((B2:B7= "A")*(C2:C7= "ZZ"),D2:D7/SUMIF(F2:F4,A2:A7,G2:G4))
    Thanks for the response daddylonglegs! How can I update this formula to gracefully handle divide by zero cases? Thanks again.

  5. #5
    Registered User
    Join Date
    02-14-2014
    Location
    Alexandria, VA
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: sumifs (or sumproduct) but with division - and a lookup

    CalcTotalHoursForProjectATypeZZ.png

    Here's what the sheet looks like. The divide by zero error occurs because Gary is not in the lookup table. How do I update =SUMPRODUCT((B2:B7= "A")*(C2:C7= "ZZ"),D2:D7/SUMIF(F2:F4,A2:A7,G2:G4)) to handle divide by zero cases? Cheers

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: sumifs (or sumproduct) but with division - and a lookup

    You could use IFERROR function in an "array formula" e.g.

    =SUM((B2:B7= "A")*(C2:C7= "ZZ")*IFERROR(D2:D7/SUMIF(F2:F4,A2:A7,G2:G4),0))

    confirmed with CTRL+SHIFT+ENTER

    ....but if the name in column A isn't in the table those hours won't be included in the calculation

  7. #7
    Registered User
    Join Date
    02-14-2014
    Location
    Alexandria, VA
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: sumifs (or sumproduct) but with division - and a lookup

    Brilliant! Thank you kindly daddylonglegs

+ 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. sumproduct division returning div/0
    By flizzn in forum Excel General
    Replies: 17
    Last Post: 02-19-2011, 02:41 PM

Tags for this Thread

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