+ Reply to Thread
Results 1 to 20 of 20

Can someone explain HOW this formula works?

  1. #1
    Registered User
    Join Date
    02-10-2016
    Location
    Blaine, mn
    MS-Off Ver
    2007
    Posts
    79

    Can someone explain HOW this formula works?

    =SUMPRODUCT(--((C$3:C$13<B16)+(D$3:D$13>B15)+(B$3:B$13>C$3:C$13)=3))

    I found this formula online, except at the end it was a =2 rather than the =3. I put the =3 in it because it wasn't exactly working the way I needed it to, and once I did that everything seemed to work just fine. But I want to understand how and why it works.

    =SUMPRODUCT(--((C$3:C$13<B16)+(D$3:D$13>B15)+(B$3:B$13>C$3:C$13)=3)) IS PLACED IN B16, B20 AND B24



    ...A.................B.............C..............D
    1
    2 DATE START STOP
    3 BEN............2/8/16......6:00......16:30
    4 ANDY..........2/8/16......6:00......16:30
    5 JUSTIN........2/8/16......6:00......16:00
    6 ROB............2/8/16
    7 MELANIE.....2/8/16......6:00......16:30
    8 CHANG.........2/8/16......6:00......16:30
    9 JOHN...........2/8/16......6:00......16:30
    10 PAUL..........2/8/16
    11 ANH...........2/8/16
    12 MATT..........2/8/16......6:00......15:30
    13
    14 START.....6:00
    15 END.......15:30
    16 WORKERS....7
    17
    18 START....15:30
    19 END.....16:00
    20 WORKER....6
    21
    22 START....16:00
    23 END......16:30
    24 WORKERS....5
    25
    26
    27

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Can someone explain HOW this formula works?

    For each row (3 to 13) it checks to see if
    1. Col C < B16,
    2. Col D > B15 and
    3. Col B > Col C
    Assigning 1 (TRUE) or 0 (False) then sums them ( so if all 3 are true, then result = 3)
    If that's true, (1+2+3)=3, then it gives that row a value of 1
    So maximum value for equation would be 11 (11 rows of true)
    Does that help?
    Last edited by ChemistB; 02-17-2016 at 11:01 AM.
    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

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Can someone explain HOW this formula works?

    Your third term does not seem likely B>C since B has a date and C a time (B will always be greater than C, unless there's a date hidden in that time cell)

  4. #4
    Registered User
    Join Date
    02-10-2016
    Location
    Blaine, mn
    MS-Off Ver
    2007
    Posts
    79

    Re: Can someone explain HOW this formula works?

    Quote Originally Posted by ChemistB View Post
    For each row (3 to 13) it checks to see if
    1. Col C < B16,
    2. Col D > B15 and
    3. Col B > Col C
    Assigning 1 (TRUE) or 0 (False) then sums them ( so if all 3 are true, then result = 3)
    If that's true, (1+2+3)=3, then it gives that row a value of 1
    So maximum value for equation would be 11 (11 rows of true)
    Does that help?
    I sort of get it.. it may take me a bit more reading it to fully get it. Would you say this is an acceptable formula for what I am trying to acheive here? Basically, I am counting how many employees are working during a specific time frame. Example 6-15:30 there were 7, and 15:30-16:00 there were 6, and from 16:00-16:30 there were 5. Each work day will be different depending when employees start or end their shifts. I use this data to determine how much to pay the job forman(they get paid more with 5-6 employees, whereas only 2-4 is less pay).

    Your help is appreciated! It seems like this formula is working, but if there is something better to use I am up to suggestions! Thanks!
    Last edited by jmrlifesafe; 02-17-2016 at 11:26 AM.

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Can someone explain HOW this formula works?

    Okay, according to your first post, Start time of 6:00 is in B14 and End time of 15:30 is in B15

    You want them to start and end between those times?
    You would do better with COUNTIFS
    =COUNTIFS(C3:C13>= B14, D3:D13<= B15)
    a much simplier formula than the SUMPRODUCT formula

  6. #6
    Registered User
    Join Date
    02-10-2016
    Location
    Blaine, mn
    MS-Off Ver
    2007
    Posts
    79

    Re: Can someone explain HOW this formula works?

    Quote Originally Posted by ChemistB View Post
    Okay, according to your first post, Start time of 6:00 is in B14 and End time of 15:30 is in B15

    You want them to start and end between those times?
    You would do better with COUNTIFS
    =COUNTIFS(C3:C13>= B14, D3:D13<= B15)
    a much simplier formula than the SUMPRODUCT formula
    I tried to paste your formula but i'm getting an error.

  7. #7
    Registered User
    Join Date
    02-10-2016
    Location
    Blaine, mn
    MS-Off Ver
    2007
    Posts
    79

    Re: Can someone explain HOW this formula works?

    Quote Originally Posted by ChemistB View Post
    Okay, according to your first post, Start time of 6:00 is in B14 and End time of 15:30 is in B15

    You want them to start and end between those times?
    You would do better with COUNTIFS
    =COUNTIFS(C3:C13>= B14, D3:D13<= B15)
    a much simplier formula than the SUMPRODUCT formula
    I tried to paste your formula but i'm getting an error.

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Can someone explain HOW this formula works?

    Oops, sorry

    =COUNTIFS(C3:C13, ">=" & B14, D3:D13, "<=" & B15)

  9. #9
    Registered User
    Join Date
    02-10-2016
    Location
    Blaine, mn
    MS-Off Ver
    2007
    Posts
    79

    Re: Can someone explain HOW this formula works?

    I tried that forumla and it doesn't work correctly. Using my data, I show that 7 employees worked between 6:00 and 15:30- whereas the formula you supplied gives me the number 1.

    This has been the hardest formula for be to figure out. LOL!! There has to be an easier way! I have to find a way to be able to put in any timeframe, and based on the timesheet start and end times, have excel tell me how many people worked between that time frame... the search continues....

  10. #10
    Registered User
    Join Date
    02-10-2016
    Location
    Blaine, mn
    MS-Off Ver
    2007
    Posts
    79

    Re: Can someone explain HOW this formula works?

    I tried that forumla and it doesn't work correctly. Using my data, I show that 7 employees worked between 6:00 and 15:30- whereas the formula you supplied gives me the number 1.

    This has been the hardest formula for be to figure out. LOL!! There has to be an easier way! I have to find a way to be able to put in any timeframe, and based on the timesheet start and end times, have excel tell me how many people worked between that time frame... the search continues....


    SORRY FOR THE DOUBLE POSTS.. SOMETHING IS WRONG WITH THIS FORUM AT THE MOMENT..

  11. #11
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Can someone explain HOW this formula works?

    Upload an example workbook and give results expected (Go Advanced>Manage Attachments)

  12. #12
    Registered User
    Join Date
    02-10-2016
    Location
    Blaine, mn
    MS-Off Ver
    2007
    Posts
    79

    Re: Can someone explain HOW this formula works?

    For some reason the attachments feature isn't working in the forum, I can't think of a way around it.

  13. #13
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Can someone explain HOW this formula works?

    Lots of forum problems today

  14. #14
    Registered User
    Join Date
    02-10-2016
    Location
    Blaine, mn
    MS-Off Ver
    2007
    Posts
    79

    Re: Can someone explain HOW this formula works?

    Go Figure!!!
    Attached Images Attached Images

  15. #15
    Registered User
    Join Date
    02-10-2016
    Location
    Blaine, mn
    MS-Off Ver
    2007
    Posts
    79

    Re: Can someone explain HOW this formula works?

    Can you see that worksheet? I see it and I can't beleive it came up.

    Anyway.. this is what I am working with.

    You will see starting at row 15
    START
    END
    Workers

    This is where I am typing in the time that I want to look at how many employees worked within that time frame. For example I want to know how many workers worked 6:00-8:00- Almost everyone worked with in that time frame. 8:00-11:30 Only 4 people worked within that time frame. So on and so forth...

  16. #16
    Registered User
    Join Date
    02-10-2016
    Location
    Blaine, mn
    MS-Off Ver
    2007
    Posts
    79

    Re: Can someone explain HOW this formula works?

    Oh and because this thread is getting so long the formula I am currently using is:
    =SUMPRODUCT(--((C$3:C$12<B15)+(D$3:D$12>B14)+(B$3:B$12>C$3:C$12)=3))

    I have no idea why it's working but it is. Someone mentioned that it's not the right way to do this. I'm looking for a way to do it.
    Attached Images Attached Images

  17. #17
    Registered User
    Join Date
    02-10-2016
    Location
    Blaine, mn
    MS-Off Ver
    2007
    Posts
    79

    Re: Can someone explain HOW this formula works?

    I just realized I keep using .jpgs which is not what you requested.
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    02-10-2016
    Location
    Blaine, mn
    MS-Off Ver
    2007
    Posts
    79

    Formula to Calculate Employees Working Within Specific Time Frames

    So I am still playing with this and unfortunately the person that reviews the data wasn't happy with the layout (to busy) so they have asked me to make it a little easier to read. So this is the same type of worksheet, and I am still using the same formula.

    I'm still looking to see if anyone beleives there is a different formula to use or if the formula I am using is acceptable (or will it give me problems). I don't understand at all how it's working, but it seems to be working very nicely.

    Formula used: =SUMPRODUCT(--((B$4:B$14<C17)+(C$4:C$14>C16)+(B$1>B$4:B$14)=3)) ON CELLS MARKED "Workers" 18,22,26 ETC
    Attached Images Attached Images
    Attached Files Attached Files

  19. #19
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Can someone explain HOW this formula works?

    Okay, I'm back.
    =SUMPRODUCT(--((N$4:N$14<O17)+(O$4:O$14>O16)=2))
    Taking the terms 1 by 1
    N$4:N$14<O17 will equal 1 whenever your person's start time is before your set end time (O17)
    (O$4:O$14>O16) will equal 1 whenever the person's end time is greater than your set start time (O16)
    The entire equation will sum the values where both the terms mentioned above are true/1 so that 1+1 = 2

    Sometimes you have a third term i.e.
    (N$1>N$4:N$14) and set the total "=3"
    N1 contains a date and it will always be greater than the time in N4:N14 so this term in not necessary.
    Shorten the formula to two terms and "=2"
    Hope this helps.

  20. #20
    Registered User
    Join Date
    02-10-2016
    Location
    Blaine, mn
    MS-Off Ver
    2007
    Posts
    79

    Re: Can someone explain HOW this formula works?

    This is great!! Thank you so much for the very good explanation and for providing the forumla. I am new to the formulas so it's quite a learning curve.

    Thanks again!

+ 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. [SOLVED] explain my formula and HOW it works (please)
    By galvinpaddy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-15-2015, 05:02 PM
  2. Explain How Specific R1C1 Formula Works
    By chouston in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-03-2013, 02:32 PM
  3. Can someone please explain how this VBA works? fast-vba-fuzzy-scoring-algorithm
    By LightingPop in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-08-2013, 04:00 AM
  4. Replies: 3
    Last Post: 11-08-2012, 09:00 AM
  5. [SOLVED] Can Someone Explain how this formula works?
    By Brightspark in forum Excel General
    Replies: 4
    Last Post: 06-08-2012, 03:40 PM
  6. Explain how vlookup works
    By rajesh.chandra in forum Excel General
    Replies: 2
    Last Post: 07-10-2009, 09:51 AM
  7. Can somebody explain to me how Bob Phillips' unique record counter works?
    By Ken Johnson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-22-2005, 06:05 PM

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