+ Reply to Thread
Results 1 to 9 of 9

Sumproduct by time & day of week

  1. #1
    Registered User
    Join Date
    11-11-2009
    Location
    Reading, England
    MS-Off Ver
    2010
    Posts
    69

    Sumproduct by time & day of week

    Hi,

    As an advance on my previous formula i am trying to make a formula which totals all the miles completed by vehicles on a Saturday between the hours of 6pm and 12 pm

    =SUMPRODUCT(--(D2:D1000=A2),(H2:$H1000>="17:00:00")+(H2:$H1000<="00:00:00"),(I1:I1000="Saturday" ),S2:S1000)

    i am using the following fromula but cannot get an answer.

    Please note,

    Column D= Vehicle Registrations
    Column I= Day of week
    Column H= Time of Day
    Column S= Miles travelled.

    The formular works fine without the day of week section (shown with the red face!)

    Does anyone know where im going wrong?

    Kind Regards, Henry

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

    Re: Sumproduct by time & day of week

    Is it just a type "Saturday" in the I column or is it a formatted date?

    If the former, then probably:


    =SUMPRODUCT(--(D2:D1000=A2),(H2:$H1000>="17:00:00")+(H2:$H1000<="00:00:00"),--(I2:I1000="Saturday"),S2:S1000)

    or if the latter, then probably this can be one option:


    Please Login or Register  to view this content.
    Last edited by NBVC; 01-22-2010 at 09:33 AM. Reason: Change I1 to I2 to match other ranges
    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
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Sumproduct by time & day of week

    In addition to above re: missing coercion...

    Your Col I range is not the same dimension as the others - this would lead to #VALUE! error

    If that does not resolve your error the next question would be:

    Does your Col I range contain dates or Text strings ? ie =ISNUMBER(I2) returns what ?

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

    Re: Sumproduct by time & day of week

    Edited considering comments above.....

    Why do you have this part?

    $H2:$H1000<="00:00:00"

    how can the time be less than zero? If you just want times between 17:00 and midnight then you don't need that part.

    You also need to convert "17:00" by using some sort of co-ercer like +0 otherwise everything will be TRUE and you'll get the wrong result....

    So incorporating those and the change to column I range as suggested above......

    =SUMPRODUCT((D2:D1000=A2)*(H2:$H1000>="17:00"+0)*(I2:I1000="Saturday"),S2:S1000)
    Last edited by daddylonglegs; 01-22-2010 at 09:40 AM.

  5. #5
    Registered User
    Join Date
    11-11-2009
    Location
    Reading, England
    MS-Off Ver
    2010
    Posts
    69

    Re: Sumproduct by time & day of week

    =TEXT(WEEKDAY(G3), "dddd") to display the weekday in this colum i have used the above formula?

    im not quite sure what you mean RE. missing coercion???

    Thanks, Henry

  6. #6
    Registered User
    Join Date
    11-11-2009
    Location
    Reading, England
    MS-Off Ver
    2010
    Posts
    69

    Re: Sumproduct by time & day of week

    Unfortunatly this formula =SUMPRODUCT(--(D2:D1000=A2),(H2:$H1000>="17:00:00")+(H2:$H1000<="00:00:00"),--(I2:I1000="Saturday"),S2:S1000 --------- Returns a '0' value

    This one returns and error =SUMPRODUCT((D2:D1000=A2)*(H2:$H1000>="17:00"+0)*(I2:I1000="Saturday"),S2:S1000)

    Im really not sure where im going wrong???

    Thanks,

    Henry

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

    Re: Sumproduct by time & day of week

    There are 3 things you definitely need to fix

    1) incorrect range - range for column I should start at row 2 as the other ranges do, i.e.

    (I2:I1000="Saturday")

    2) A "co-ercer" like -- before that part, i.e. (I2:I1000="Saturday")

    Those 2 both suggested by NBVC and DO

    3) you also need co-ercer on the time values so adapting the vaersion posted by NBVC that would become

    =SUMPRODUCT(--(D2:D1000=A2),(H2:$H1000>="17:00:00"+0)+(H2:$H1000<="00:00:00"+0),--(I2:I1000="Saturday"),S2:S1000)

    In my post above I used a slightly different syntax and took out the second time check which is redundant here (but you might need that if you want to check for 17:00 to 05:00)
    Last edited by daddylonglegs; 01-22-2010 at 09:55 AM.

  8. #8
    Registered User
    Join Date
    11-11-2009
    Location
    Reading, England
    MS-Off Ver
    2010
    Posts
    69

    Re: Sumproduct by time & day of week

    =SUMPRODUCT(--(D2:D1000=A3),(H2:$H1000>="17:00:00"+0)+(H2:$H1000<="00:00:00"+0),--(I2:I1000="Saturday"),S2:S1000)

    I have changed this as advise and it is no longer shwing an error, but now only giving a "0" value, I think we're getting closer.

    Daddy Long Legs, In respose to your question RE. Times, I am just trying to find the hours done between 5pm and midnight on a saturday if this helps. I am therefore not sure wheather i need to <00:00:00 part or not?

    Thanks for your help with this, it is greatly appreciated.

    Henry

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

    Re: Sumproduct by time & day of week

    If you click on any cell within column I that has a "Saturday" in it.. what do you see in the formula Bar?

+ 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