+ Reply to Thread
Results 1 to 10 of 10

Next Assignment Due - Not Working (Strange behavior)

  1. #1
    Forum Contributor delaing's Avatar
    Join Date
    07-16-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    192

    Next Assignment Due - Not Working (Strange behavior)

    I decided to create an alternative post on this Formula board to help eliminate confusion which may come from the VBA-related post it was sourced from.
    This is the post where I extracted this from: http://www.excelforum.com/excel-prog...eted-date.html and put a note in there to reference to this board, to eliminate double-posting.
    ========================================================

    I've run into a problem with the formula which I adapted from tigeravatar's post#6 suggestion in that referenced post.

    The formula in A3 of Assignment Schedule is intended to show the next assignment I need to work. The assignment with the nearest (to Today) 'Trial Date", with no date in the "Supplement Date" column, and either marked as a C or R in the "Test for Comm or Rez" column, depending on the reference selected in C3 of the Assignment Schedule worksheet.

    Here is a view of what a good result of the formula looks like and what you will see when you first open the test workbook:

    good result1.jpg

    I am using the same formula for the B3 cell but Indexing to the CauseNum column on Data dump.
    If I can fix the formula for the Cause Name, I can apply the same fix for the B3 version.

    I've attached a test workbook with the formula which should fail if you will do this:
    On Data dump, enter today's date in F14, clearing CFT as the next case to work.
    Trustees Maritime Assn should show as the next case to work since its Supplement Date is empty, yet you should see the #NA error in A3.
    Now, change the date in Data dump B15 to 1/9/2017 and you should see Trustees Maritime as the next case to work in A3.

    Toggle back 'n forth between the 1/9/17 and 1/16/17 dates in Data dump B15 to see it switch from error to good result.

    What is wrong with the formula? Or is something wrong with the column references?

    Again, this has been working perfectly for two weeks worth of use until I came to a case with a two-digit day for the Trial Date instead of a one-digit day. I can't imagine that is the issue, but that is a strange behavior.

    Let me know what you think.

    Frustrated,
    Delain
    Attached Files Attached Files

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Next Assignment Due - Not Working (Strange behavior)

    The formula in A3 of Assignment Schedule is intended to show the next assignment I need to work. The assignment with the nearest (to Today) 'Trial Date", with no date in the "Supplement Date" column,
    If I understand correctly you want to treat "skipped" the same as "" (empty string).

    If that is the case you could try array entering this in A3.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    While it behaves differently, it is not returning as
    I've attached a test workbook with the formula which should fail if you will do this:
    On Data dump, enter today's date in F14, clearing CFT as the next case to work.
    Trustees Maritime Assn should show as the next case to work since its Supplement Date is empty, yet you should see the #NA error in A3.
    Now, change the date in Data dump B15 to 1/9/2017 and you should see Trustees Maritime as the next case to work in A3.
    If instead I also change B15 to today's date A3 returns Trustees Maritime Assn ... which is consistent with the logic of the previous post ...

    What am I missing?
    Last edited by FlameRetired; 10-19-2016 at 12:05 PM.
    Dave

  3. #3
    Forum Contributor delaing's Avatar
    Join Date
    07-16-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    192

    Re: Next Assignment Due - Not Working (Strange behavior)

    Dave, thanks for the quick interest in this. This has been extremely frustrating for me.

    Your suggestion indeed shows a result; however, I'm wanting the formula to show results where the Supplement Date is empty - unless I figure out some other scheme. So, for now "skipped" needs to be sorta seen as a date or place holder.

    What you're seeing with the test workbook is a simplified version of the production workbook which has a command button that enter a completion date in this column. Also, I have a button which enters "skipped" into the appropriate row field which allows the original formula to skip to the next record that does not have a Supplement Date. Later, I have another command which changes the Cause Name & Number formulas to find the ones which have "skipped" so that I can come back to those and work them. These buttons have nothing to with the functioning of this problem formula.

    Were you able to see the behavior I described in the test workbook?

    Again the formula in A3 works as needed, as I tried to describe its intended use, and has been working until I hit a date that has two digits as the Day. That's what I was trying to demonstrate with the test xlsx. I don't care so much about figuring that part out; I am simply looking for a working formula.

    Suggestions?

    Thank you,
    Delain

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Next Assignment Due - Not Working (Strange behavior)

    Trustees Maritime Assn should show as the next case to work since its Supplement Date is empty, yet you should see the #NA error in A3.


    Which should it be? Indeed I see the #NA / Trustees Maritime... toggle as you describe. So with the understanding that it is to return Trustees Maritime.. also with 1/16/2017 in B15 try this.

    Changed this
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    to this
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and with today's date in F14 the return is Trustees Maritime Assn whether the date in B15 is 1/16/2017 or 1/9/2017.

    I don't know how this will affect the rest of the project. I only know that it affects this particular combination of dates as above.

    Is this what you are expecting?

  5. #5
    Forum Contributor delaing's Avatar
    Join Date
    07-16-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    192

    Re: Next Assignment Due - Not Working (Strange behavior)

    Has anyone ever used "genius" and "FlameRetired" in the same sentence when talking about you?
    Man o' man!!! I had a feeling it might only be a comma or some simple fix, since the formula was working up to recently.
    And I fixed the formula in the next-door cell as well with this.

    This is beautiful. Okay, so by the confused look on your face, above, you did see the strange behavior??

    If you can give me another few moments, can you please explain what is going on with this formula and what your fix (greater than, equal to) does? I got the original formula from another expert.
    Please Login or Register  to view this content.
    I don't quite get the Match function here.

    What does the "1" do as the lookup value?
    How is the IF statement working here?

    You're a genius FlameRetired!!

    Thank you,
    Delain
    Last edited by delaing; 10-19-2016 at 01:51 PM. Reason: Forgot to finish with the genius.

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Next Assignment Due - Not Working (Strange behavior)

    Thank you for the kind words and the rep.

    I will do my best to explain. I would encourage you to study the presentation on arrays here.

    http://xldynamic.com/source/xld.SUMPRODUCT.html

    The reason I suggest this is because:
    • This formula generates a rather complex array of TRUE / FALSE
    • Any explanations I give here are going to be a bit "kludgy".
    • That presentation greatly simplifies the concepts. (No "kludge")
    • There is no need for me to re-invent the wheel.

    Having said that, here comes the "kludge".

    Let's start with the original formula. Type 1/9/2017 in B15.

    =INDEX(CauseNMs,MATCH(1,(TrialDates=MIN(IF(SuppDates="",TrialDates)))*(Comm_or_Rez=$C$3)*(SuppDates=""),0))

    Each factor in that blued part generates an array of TRUE / FALSE. Applying math operators to them coerce TRUE / FALSE into their underlying numeric values 1s and 0s. The effect of multiplying produces a logic AND ... more 1s and 0s. Again, check that link above out. It will become clearer.

    In the formula bar select those blue parts above. Press the F9 function key and you will see this array.

    {0;0;0;0;0;0;0;0;0;0;0;0;0;1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0}

    The ";" are understood to be array row separators. MATCH attempts to match the first occurrence of 1 in that array and return the row number in which it is found. In this case 14. Since that is in the row argument of INDEX it tells INDEX to return the data in the 14th row of CauseNMs which is Trustees Maritime Assn ILA vs HCAD.

    Change the date in B15 to 1/16/2017. You get the #N/A error. Perform the same selection and press F9 and you see this array.

    {0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0}

    It's all zeros. MATCH can find no 1s to match and returns #N/A.

    Now use the revised formula,

    =INDEX(CauseNMs,MATCH(1,(TrialDates > = MIN(IF(SuppDates="",TrialDates)))*(Comm_or_Rez=$C$3)*(SuppDates=""),0))

    select the same section and press F9 now. The array is ...

    {0;0;0;0;0;0;0;0;0;0;0;0;0;1;1;0;1;1;0;1;1;1;1;1;1;0;1;1;1;1;1;1;1;1;0;1;1;1;0;0;0;1;1;1;1;1;1;0;0;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1}

    Remember that MATCH attempts to match the first 1 in the array. Again that is row 14.

    Now change the date in B15 back to 1/9/2017, do the select / F9 steps again and you will see the identical array with a match return of 14.

    Another way to gain insight into formulas is use of Evaluate Formula ... Fx for short. Click FORMULAS in the ribbon > Evaluate Formula. Clicking the Evaluate button repeatedly reveals how Excel calculates step by step. In this case the array is large and the view port painfully small. There is a scroll bar though.

    These two devices F9 and Fx are helpful for self instruction and formula dissection. I recommend them whenever I can.

    That said and regarding the IF portion of the formula I would suggest copying that and in a temporary cell enter that formula section by itself and apply Fx. "Explanation" is likely more complex than I am prepared to do well. It is a component of one of the factors. The formula will explain itself better inside Fx.

    I hope I didn't leave anything out. LOL

    Did this help?

  7. #7
    Forum Contributor delaing's Avatar
    Join Date
    07-16-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    192

    Re: Next Assignment Due - Not Working (Strange behavior)

    It very much helped. I've been using F9 for quite some time just as you explained, but I did not know about the Evaluate. I will definitely add that to my arsenal. It will take me some time to go through the write up on Sumproduct to glean more on Arrays, as you suggested.

    What I didn't see is how you might've been led to try the greater-than operator, from that article. Do you know what was causing the original formula to hang up with just the equal(=) operator?

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Next Assignment Due - Not Working (Strange behavior)

    All I had was the sense of the formula and prior thread, the behaviors you described and the output you expected. After that it was a process of elimination.


    Do you know what was causing the original formula to hang up with just the equal(=) operator?
    After the filtering of the MATCH function there could be no TrialDates equal to 1/9/2017 unless B15 was changed to that. The only way I could see to get the earliest TrialDate with 1/16/2017 in B15 was to change the criteria to match the first date greater than or equal to the results of the MIN / IF.

    I must admit my eyes glazed over several times examining the array build. Kudos to tigeravatar who did all the heavy lifting in that thread.
    Last edited by FlameRetired; 10-19-2016 at 06:41 PM.

  9. #9
    Forum Contributor delaing's Avatar
    Join Date
    07-16-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    192

    Re: Next Assignment Due - Not Working (Strange behavior)

    Hopefully a better understanding of the formula will come to me the more I use it.
    Thanks for all the good insight.

    Done,
    Delain

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Next Assignment Due - Not Working (Strange behavior)

    You're welcome. Thanks again for the feedback.

    Hopefully a better understanding of the formula will come to me the more I use it.
    Yup. That's been my experience.

+ 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. GetPivotData - strange behavior
    By baijixu in forum Excel General
    Replies: 4
    Last Post: 11-09-2013, 12:27 PM
  2. Strange behavior of pivot
    By roberto21 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-21-2013, 05:13 PM
  3. Strange Findlastrow behavior.
    By DECROMAX in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-16-2013, 08:03 PM
  4. Userform strange behavior
    By Shaun_email in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-09-2007, 07:47 PM
  5. VBA - Strange behavior
    By MVM in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-12-2006, 02:50 PM
  6. [SOLVED] Strange TAB behavior
    By m davidson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-28-2006, 01:15 PM
  7. [SOLVED] Strange behavior.
    By Wiley Coyote in forum Excel General
    Replies: 7
    Last Post: 10-18-2005, 12:05 PM
  8. [SOLVED] Strange VBE Behavior
    By Jeff Robson in forum Excel General
    Replies: 4
    Last Post: 01-14-2005, 07:06 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