+ Reply to Thread
Results 1 to 8 of 8

How exactly does this formula work?

Hybrid View

  1. #1
    Registered User
    Join Date
    11-11-2014
    Location
    Manila, Philippines
    MS-Off Ver
    2010
    Posts
    8

    Question How exactly does this formula work?

    =SUM(IF((C3>J$3:J$50000)*(B3<K$3:K$50000)*(A3=I$3:I$50000),((IF(C3<K$3:K$50000,C3,K$3:K$50000)-IF(J$3:J$50000>B3,J$3:J$50000,B3))*24*60),0))

    Formula above is set as an array.

    Column C contains end date and time (e.g. 3/6/16 0:30:00) of a schedule pair.
    Column J contains start date and time (3/5/2016 0:01) of LogInLogOut pair.
    Column B contains start date and time of a schedule pair.
    Column K contains end date and time of a LogInLogOut pair
    Columns A & I contains employee IDs.

    Please explain exactly how it works because while I understand that the formula basically sums the minutes that fit within the schedule, I don't know how it does that in a step-by-step manner.

    Thanks in advance!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How exactly does this formula work?

    The the FIRST IF() function filters out rows that are completely outside of the range start/end times.

    Then the SECOND IF() function is doing the work. It is reconstructing the array of time values creating a new table that changes the values to ONLY include the minutes within the desired time range.

    If the start time is earlier than the range start time, the range start time is substituted in, else the original start remains.
    If the end time is later than the range end time, the range end time is substituted in, else the original end remains.

    The remaining values in the newly constituted table are summed.


    If you change your range of rows down to say only 5 rows, all through the formula, then you would be able to sue the FORMULAS tab > Evaluate Formula to watch this baby unfold before your eyes. Very fun to watch.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: How exactly does this formula work?

    I had to attach this as a text file because the board thinks my greater than and less than are HTML code tags.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How exactly does this formula work?

    the board thinks my greater than and less than are HTML code tags
    Add a space after them.

    This is apparently an array formula

    I'll try to take it in pieces. Wherever I see a range using J I substituted startpair, whenever I see a range using K I substituted endpair - this is what it would look like if you were using Excel Tables.

    I exploded out the formula to explain it better

    =SUM(
    IF(
    (C3 > startpair)*(B3 < endpair)*(A3 = employeenumber),
    (
    (IF(C3 < endpair, C3, endpair) - IF(startpair > B3, startpair, B3) ) *24 * 60)
    ,0)
    )
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    11-11-2014
    Location
    Manila, Philippines
    MS-Off Ver
    2010
    Posts
    8

    Re: How exactly does this formula work?

    Whoa!
    Thanks!
    Might be a noob question but what does the * do in the first IF?

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: How exactly does this formula work?

    The * works sort of like a logical AND statement in an array formula.

    This article explains the concept behind array formulas.

  7. #7
    Registered User
    Join Date
    11-11-2014
    Location
    Manila, Philippines
    MS-Off Ver
    2010
    Posts
    8

    Re: How exactly does this formula work?

    I'm sorry. But I don't see the article and I'd really want to read it. Specially since Google hasn't been helpful (or my key/searchwords suck).

  8. #8
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: How exactly does this formula work?


+ 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] Formula in one work sheet wont accept result from another in a different work sheet.
    By Belinea2010 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-07-2015, 12:24 PM
  2. Replies: 9
    Last Post: 11-19-2014, 04:15 PM
  3. Why does my formula work in Excel 2013 but not-work in SharePoint 2013?
    By mkamoski in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-11-2014, 06:37 PM
  4. [SOLVED] weekday() result used in an array formula doesn't work. Formula works if i type in date
    By aarco50 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-25-2014, 03:25 PM
  5. Replies: 0
    Last Post: 11-12-2012, 04:49 AM
  6. Trying to work formula for work TIME SHEET using IF formula
    By help_monique in forum Excel General
    Replies: 8
    Last Post: 10-12-2009, 11:46 PM
  7. Replies: 2
    Last Post: 11-30-2005, 06:15 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