+ Reply to Thread
Results 1 to 12 of 12

Nesting issues

  1. #1
    Registered User
    Join Date
    08-05-2023
    Location
    Michigan, US
    MS-Off Ver
    365
    Posts
    6

    Nesting issues

    Hello! I'm trying to create a nesting formula and I can get each one to work independently, but when I nest them altogether, some of them don't work anymore and I can't figure out why. Mainly, they are the ones where I'm trying to calculate an average if the amounts are all <=2.00. I do have separate formulas for the amounts >2.00 because those calculations depend on other factors which work both independently and in the nesting formula. I have tried changing the independent formulas to get them to work in the nest to no avail.
    This is where I left off at and I'm referencing Column I because that has two of the conditions that don't work. These are the segments that don't work in the nest:
    IF(OR(J4={"REF","OTDT"},AND($B$2:$P$2,"12",$B$3:$P$3,"OT W","<=2.00")),(AVERAGEIFS($B4:$P4,$B$3:$P$3,"OT W",$B4:$P4,">0.17",$B$3:$P$3,"OT W",$B4:$P4,"<=2.00")-$H4),
    IF(OR(J4={"REF","OTDT"},AND($B$2:$P$2,"10",$B$3:$P$3,"OT W","<=2.00")),(AVERAGEIFS($B4:$P4,$B$3:$P$3,"OT W",$B4:$P4,">0.17",$B$3:$P$3,"OT W",$B4:$P4,"<=2.00")-$H4),
    IF(OR(J4={"LV","SC"},AND($B$2:$P$2,"12",$B$3:$P$3,"OT W","<=2.00")),AVERAGEIFS($B4:$P4,$B$3:$P$3,"OT W",$B4:$P4,">0.17",$B4:$P4,"<2.01"),
    IF(OR(J4={"LV","SC"},AND($B$2:$P$2,"10",$B$3:$P$3,"OT W","<=2.00")),AVERAGEIFS($B4:$P4,$B$3:$P$3,"OT W",$B4:$P4,">0.17",$B4:$P4,"<2.01"),
    I have attached a shortened version of my worksheet to show the representative data. The formula will go under each Carrier's column labeled "U" (for unavailable).
    Any help/guidance would be much appreciated!
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    08-08-2023
    Location
    Texas, USA
    MS-Off Ver
    MS Office 365
    Posts
    49

    Re: Nesting issues

    My first thought is to use the LET function to make the function easier to follow, working on it now.

  3. #3
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Nesting issues

    My first thought is, describe first in a natural language under which conditions something has to be calculated and supplement this description with concrete examples.

    By the way:
    I think the formula contains strange conditions, which react very differently, as you expect.
    And also different as I expected.
    For example: =OR(J4={"REF","OTDT"},AND($B$2:$P$2,"12",$B$3:$P$3,"OT W","<=2.00") ) returns TRUE. I myself expected #VALUE. I think you expected FALSE.
    Last edited by HansDouwe; 09-06-2023 at 06:21 PM.

  4. #4
    Registered User
    Join Date
    08-05-2023
    Location
    Michigan, US
    MS-Off Ver
    365
    Posts
    6

    Re: Nesting issues

    Our worksheet is to track overtime that people work (OT W) and at the end of each quarter, we are required to keep everyone within 10% of the top overtime worker. There are two different overtime lists people can sign up for per quarter, 10 hours (2 hrs of OT) and 12 hours (4 hrs of OT) that apply each day. When someone is not available to work OT, then they are marked unavailable ("U"), and the reason why under their "Key" column, which has a drop-down list to select the reason. The worksheet we are trying to create is to average out the hours that people worked on any given day, and depending on which list they are on (10/12), what to charge those that were unavailable based on the reason "Key". Anyone on the 10/hr list will be charged for any difference the 12/hr list works over 10 hours, unless they are mandated to work over 10 hours, to help keep them within the 10% of the top worker we are required to. We've been manually calculating every day OT is worked and are trying to come up with a solution with this as sometimes we have around 25 people on the overtime lists and it's very time consuming. This is the breakdown of the formula in C4 and each "Key" reason someone could be unavailable, and how we expect them to be charged:
    D4=

    "",0 - there was no OT that day or the person worked the OT offered so there is no reason to charge them unavailable.

    "HOL",0 - Holiday schedule, we have rotating days off, so if someone works their day off and it's also on a holiday or holiday schedule, the 8 hours of OT does not count toward the equitability. If they work more than 8 hours on their day off, then anything over 8 is counted. This just helps us track why they work a day off and it's not computed on the worksheet.

    "MU",0 - If someone wasn't within the 10% at the end of the previous quarter, they are given the difference as a negative amount in the "OT W" in the new quarter and this is how we track it so hopefully they'll be caught up by the end of the current quarter. (Make Up hours)

    "MAX",0 - If someone has already worked the maximum hours allowed, per our contract, we can no longer offer them or charge them unavailable, usually only happens during our peak season and they work both days offs along with some daily OT. This is how we notate why there's no OT W or Unavailable.

    "OFF LIST",0 - At any time, an employee can get off the overtime list they signed up for and this is how we notate it on the worksheet as to why they will have no more OT worked or unavailable charged.

    "RDO",8 - This is the employee turning down an offer to work their day off, they gave up 8 hours of overtime. (Refused Day Off)

    Here is the part that comes to the averaging:

    "10LIST" - This is to keep the 10 hr list equitable to the 12 hr list. Applies when the 12 hr list works over 10 hours (more than 2 hours of OT) and the 10 hr list only worked up to 10 hours. Averages the the hours the 12 list worked over 2 hours and then subtracts what the 10 list worked. So on 5/23, 2 of the 12 list worked an average of 3.67 hours, their was one 10 list that worked 1.67 hrs so they are marked "10LIST" and charged 2 hours unavailable. 3.67-1.67=2.00, The two that were marked "LV" (on leave/vacation/called in sick) are charged the whole 3.67 hrs regardless of what list they are on.

    "REF" or "OTDT" - Refused/Overtime in Downtime: The employee refused/declined some or all of the overtime offered, or they did the some or all of the overtime offered faster than anticipated (less than 8 hrs) and then refused/declined to do more. Again, this will average what the others worked, and depending if the person that refused or did work some OT, that will be subtracted from the average and they will be charged unavailable for the difference. This is a bit tricky because unlike the "10LIST" where the formula takes only the 12 list people to average the OT W, this could be a combination of both 10 and 12 lists that work the full OT offered so defining which OT W to calculate the average can either be over 2 hrs or under 2 hrs. The other caveat is that the average can't include what the "REF" or "OTDT" carriers worked and sometimes the 10LIST if under 2 hrs, because it skews the average to lower than what it should be. As you can see in the worksheet I attached, it works for the over 2 hrs, but not for the 2 hrs and under. I did try create a formula to exclude "REF", "OTDT", and "10LIST" in the average but couldn't figure it out to work correctly. For this one on 5/27, there was a 12 list that worked 2.66, a 12 list that did part if on down time and only worked .50 of overtime, and a 10 list that worked 1.98. To get the everyone to what the 12 list worked at 2.66, I need the formula to average anything over 2 hrs. In this case, just the one person. The formula works where it took the 2.66 and then subtracted what the other 12 list worked, .50 and charged unavailable for 2.16 for OTDT, and the for the 10 list person, subtracted what they worked 1.98 to charge them .68 for 10LIST.
    The formula doesn't work when it needs to average time at 2 hours or less as seen on 5/29.

    "LV" and "SC" - The employee is on some kind of leave (vacation/sick) or they are on a change of schedule where they are not allowed to work OT that day. This charges them unavailable for the full amount of the average the other people worked. The formula works for anything worked over 2 hrs but not 2 hrs and under. This is similar to the REF, OTDT, and 10LIST where some of them need to be excluded from calculating the average and also there is nothing to subtract from the average. On 5/23 and 5/24 it works because the hours are over 2.00, but doesn't work on 5/28 or 5/29.

    I hope that helps explain what we're trying to accomplish. We've been working on this sporadically for the last couple of months.
    Last edited by kckliodna; 09-07-2023 at 11:00 AM.

  5. #5
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Nesting issues

    Thank you for your explanation, but not everything is clear to me.
    For the following questions I refer to your formula in cell C4.
    Please Login or Register  to view this content.
    Looking at your formula it seems that if the code is not 10LIST you don't want to distinguish between the 10's and 12's.
    After all, the averages in lines 3 and 4 are the same.
    This also applies to the averages in lines 5 and 6, the averages in lines 7 and 8 and the averages in lines 9 and 10.
    Is that right?

    I don't understand when exactly which average should be calculated.
    Your condition states something like >2.00 and <= 2.00, but it is unclear to me what should be >2.00 or less than 2.00. [In case of the formula in C4].
    Even if the reference is to multiple numbers, what should happen when part of those numbers is greater than 2 and another part is less than 2?
    After all, only 1 average can be calculated by the formula.

    In addition, the conditions you mean must be written down in a completely different way.
    The condition in line 3 always returns TRUE (to my surprise, because I expected an error).
    Last edited by HansDouwe; 09-07-2023 at 11:36 AM.

  6. #6
    Registered User
    Join Date
    08-05-2023
    Location
    Michigan, US
    MS-Off Ver
    365
    Posts
    6

    Re: Nesting issues

    You are correct for 10LIST not needing to distinguish between 10's and 12's. This part of the formula will only average what the 12's worked >2.00, then subtract what the 10LIST worked.

    The overtime worked is entered in each person's "OT W" column for each day. So in row 4, 3 people worked overtime, 2 are 12 list and 1 is 10 list. The other two are on leave (LV).

    It is the data that is in the "OT W" columns, across each row, for each person that needs to be used to average. For the example worksheet, the first date 5/23, in row 4, that would B4, E4, H4, K4, and N4.

    Using row 4, first I need it to look at the data entered into all of "OT W" across the row and determine if any of the values are >2.00. If they are, then I need to look at if the person is on the 10 list or 12 list, as indicated in row 2 for all people, B2, E2, H2, L2, etc. Because some of the values in the OTW cells are >2, depending on what "Key" code is selected, is where the formula will come into play to determine which one of the nested formulas to follow to provide the average.

    As long as some of the data in the OT W cells across the row is >2.00, LV, SC, 10LIST, REF, OTDT will always calculate only those cells that are >2.00 to determine an average, regardless of what list someone is on. If it <=2.00, it will not use that data to calculate the average. In row 4, there are three values in OT W, 3.45, 3.88 and 1.67. The formula only calculates the average of 3.45 and 3.88 to be 3.67 and enters it. Same with row 5, there are two values in OT W, 3.00 and 2.00. The formula ignores the 2.00 and uses 3.00 as the average since it’s the only one >2.00.

    10LIST, REF, OTDT does the same thing as long as some of the data in the OT W cells across a row is >2.00, except it goes one step further to take the average of 3.67 and subtracts what was in the OT W cell of the person that was coded as one of those 3. So row 4, Carrier E, is on the 10 list, worked 1.67, so the formula takes the average of 3.67 and subtracts 1.67 to enter a value of 2.00. If there is no OT W in the people coded, it will enter the whole average.

    The part of the formula not working is if ALL the data in OT W across a row in <=2.00. For some reason I can get it to work independently, but not nested. The portions of

    IF(OR(G5={"REF","OTDT"},AND($B$2:$P$2,"12",$B$3:$P$3,"OT W","<=2.00")),(AVERAGEIFS($B5:$P5,$B$3:$P$3,"OT W",$B5:$P5,">0.17",$B$3:$P$3,"OT W",$B5:$P5,"<=2.00")-$E5),

    IF(OR(G5={"REF","OTDT"},AND($B$2:$P$2,"10",$B$3:$P$3,"OT W","<=2.00")),(AVERAGEIFS($B5:$P5,$B$3:$P$3,"OT W",$B5:$P5,">0.17",$B$3:$P$3,"OT W",$B5:$P5,"<=2.00")-$E5),

    IF(OR(G5={"LV","SC"},AND($B$2:$P$2,"12",$B$3:$P$3,"OT W","<=2.00")),AVERAGEIFS($B5:$P5,$B$3:$P$3,"OT W",$B5:$P5,">0.17",$B5:$P5,"<2.01"),

    IF(OR(G5={"LV","SC"},AND($B$2:$P$2,"10",$B$3:$P$3,"OT W","<=2.00")),AVERAGEIFS($B5:$P5,$B$3:$P$3,"OT W",$B5:$P5,">0.17",$B5:$P5,"<2.01")

    When I was making the formulas, at first I didn’t differentiate between the 10 list and 12 list and this caused it to include all the OT W regardless of being over 2.00 and more often than not, I would get the “VALUE!” error which I think you are referring to that you expected. By differentiating the list in the formula, it calculated it the way I wanted it to. I have no idea why it works that way. It’s the same as I can get each formula to work independently and give me the results I want, but once I nest them, some won’t work, which makes no sense to me.

    Ideally, I would like the last formula if false to be IF(OR(G5={"LV","SC"},AND($B$2:$P$2,"10",$B$3:$P$3,"OT W","<=2.00")),AVERAGEIFS($B5:$P5,$B$3:$P$3,"OT W",$B5:$P5,">0.17",$B5:$P5,"<2.01")
    Without the zero as the “if false” answer because I already have in the formula which codes I want to give zero as the value (“”, HOL, MU, MAX, and OFF LIST).

  7. #7
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Nesting issues

    Do I understand correctly that if at least 1 value OT W is present in a row with a value > 2.00, then lines 3 to 6 of the formula should be used
    and if no value is greater than 2.00, then lines 7 to 10 of the formula must be used.

    I don't yet fully understand the distinction you want to make in lines 3 to 10 with the 10's and 12's.
    After all, whether line 3 or line 4 of the formula is executed, it will lead to the same average.
    After all, the calculation of these two lines is exactly the same.

    The same applies to lines 5 and 6, lines 7 and 8 and lines 9 and 10.

    Please can you go into more detail about this?

    For some reason I can get it to work independently, but not nested.
    The problem is not the nesting, the problem here is the way the conditions are formulated is not right. This needs to be adjusted on several points, but because I don't exactly understand the conditions you mean, I'll ask you more about this in detail.

  8. #8
    Registered User
    Join Date
    08-05-2023
    Location
    Michigan, US
    MS-Off Ver
    365
    Posts
    6

    Re: Nesting issues

    If there is at least 1 value in a row with a value of > 2.00 in the OT W columns, then lines 3,4,7 and 8 should be used. If no value is greater than 2.00, then lines 5,6,9 and 10 should be used.

    The averages for 3 and 4 are the same result, but if I take out the part that distinguishes between “10” and “12” from the formula, depending on whether the person being calculated is a 10 list or 12 list, the formula won't work. In my worksheet, using Carrier C (12 list) where there is a REF code used, if I were to reduce the formula to take out the 10 and 12 references and combine lines 3 and 4 to:

    IF(OR(D4={"REF","OTDT"},AND($B$3:$P$3,"OT W",">2.00")),(AVERAGEIFS($B4:$P4,$B$3:$P$3,"OT W",$B4:$P4,">2.00")-$B4),
    The formula doesn't work and returns #VALUE!

    If I remove line 3 completely and leave line 4, it does work for both lists. It is the same if I remove line 4 and leave line 3; it works for both lists. I guess in my head when creating this, I thought it looked odd to have only the one list referenced in the formula, so I created both. I was able to combine the two this way, and it works, again keeping both the 10 and 12 references, but at least it's not done twice this way:

    IF(OR(D5={"REF","OTDT"},AND($B$2:$P$2,"12",$B$3:$P$3,"OT W",">2.00",$B$2:$P$2,"10",$B$3:$P$3,"OT W",">2.00")),(AVERAGEIFS($B5:$P5,$B$3:$P$3,"OT W",$B5:$P5,">2.00")-$B5)

    All I know is if I take out the reference to $B$2:$P$2, it gives the #VALUE!

    Because of the 2 overtime lists, 10 and 12, and I need to keep the 10 list within 10% of the top working person by the end of the quarter, I need to be able to charge the 10 list any hours >2.00 unless they do work more than 2.00 of overtime. That is why I need two different calculations. If there is any one person that works over 2.00, then the formula will calculate only those values greater than 2.00; if not, then the formula needs to average all the values between 0.17 and 2.00, including 2.00. If REF or OTDT are the codes chosen, I need the formula to do the same thing but subtract any OT W the person may have worked.

    I do need to reference the OT W column because, in my full worksheet, there are other columns that I did not include in the sample worksheet because I didn't want it to be too much per the upload instructions. Each person has 7 columns of data, but the three I included are the ones that are giving me issues. I have attached a new worksheet that is a smaller portion of my actual worksheet with a few people, so maybe that will help. Just know that the formula in the "U" columns in that one doesn't work either. In that particular formula, if I switch where I have "OR" for "AND", it will give me values for <= 2.00 but not > 2.00

  9. #9
    Registered User
    Join Date
    08-05-2023
    Location
    Michigan, US
    MS-Off Ver
    365
    Posts
    6

    Re: Nesting issues

    Oops, forgot to upload the new worksheet sample
    Attached Files Attached Files

  10. #10
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Nesting issues

    Please try in C4 and copy down and copy to the other columns:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by HansDouwe; 09-10-2023 at 01:13 AM.

  11. #11
    Registered User
    Join Date
    08-05-2023
    Location
    Michigan, US
    MS-Off Ver
    365
    Posts
    6

    Re: Nesting issues

    AWESOME! It works! I think I understand the formula except the IF(SUM(N - what does the N reference or apply to? Also, after seeing the LET function, I'm going back through some of my formulas and using that to shorten them up! It's been over 10 years since I've done creative formula work in Excel so I'm very rusty and there's so much new stuff to learn. Much appreciated - THANK YOU!!

  12. #12
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Nesting issues

    Thanks for the feedback and rep . Glad to have helped.

    In this formula translates the function N the result of a Boolean expression TRUE or FALSE in 1 or 0, after which SUM is possible.

    Other methods to translate the result of a Booelan expression into a 0 or a 1 is to place the expression in a calculation (with an operand).
    For example, by placing 0+ or ​​1* or -- in front of it.

+ 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. Replies: 1
    Last Post: 05-10-2021, 11:21 AM
  2. Urgent nesting calculation issues
    By asills03 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-03-2018, 04:34 AM
  3. [SOLVED] Excel to Outlook Calendar date duplication issues and blank cells causing issues
    By singerbatfink in forum Outlook Formatting & Functions
    Replies: 0
    Last Post: 02-11-2016, 07:57 AM
  4. Replies: 4
    Last Post: 02-26-2015, 06:10 AM
  5. Nesting Issues
    By demoman369 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-17-2014, 06:59 PM
  6. Replies: 3
    Last Post: 07-16-2014, 01:50 AM
  7. Nesting issues
    By Shmem in forum Excel General
    Replies: 12
    Last Post: 11-12-2009, 08:07 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