Forum Discussion

SGeorgie's avatar
SGeorgie
Brass Contributor
Nov 13, 2023

IF FORMULA - Help Needed please

Hi

 

Im trying to write an IF formula and its erroring 

 

Basically I this formula worked but i needed the 'not completed' part added!

 

=IF(L4>TODAY(),"Compliant", IF(P4>TODAY(),"Pending",IF(V4>TODAY(),"Pending","Not Completed")))

 

 

want to say if 'L4 is today or in the future bring back 'Completed' but if less than today 'Expired'

if P4 or VA are today or in the future to bring back 'Pending', or if none of the columns have any dates 'Not Completed'

 

HOW DO I WRITE THIS PLEASE?????  URGENT HELP NEEDED

31 Replies

  • djclements's avatar
    djclements
    Silver Contributor

    SGeorgie While reading through this thread, I noticed some conflicting statements made about the logic. However, looking at your original question with the first formula your tried, then comparing that to the last formula you tried, I think this might be what you want:

     

    =IFS(AND(ISBLANK(K4),ISBLANK(O4),ISBLANK(U4)), "Not Completed", K4>=TODAY(), "Compliant", OR(O4>=TODAY(), U4>=TODAY()), "Pending", TRUE, "Expired")

     

    The IFS function evaluates each logical test in order and returns the corresponding value for the first TRUE result found. When a logical test returns TRUE, none of the subsequent tests will even be evaluated, so it's important to get the order correct. The above formula is evaluated as follows:

     

    1. The first logical test checks if ALL date cells are blank. If TRUE, it returns "Not Completed" and does not evaluate any further.
    2. The second logical test checks if K4 is greater than or equal to TODAY(). If TRUE, it returns "Compliant", regardless of the other dates.
    3. For the third logical test, there is no need to check if K4 is less than TODAY(), because that's already a given, since the second logical test returned FALSE. At this point it's only necessary to check if either O4 or U4 is greater than or equal to TODAY(). If TRUE, it returns "Pending".
    4. Finally, if all three logical tests return FALSE, that means one or more dates are already entered, and they are all in the past, so there is no reason to conduct any further logical tests. Simply use TRUE for the expression to return "Expired".

    I hope this works as expected, or at least serves as a guide for how to use the IFS function correctly to figure out the logic you need.

    • SGeorgie's avatar
      SGeorgie
      Brass Contributor
      Also one row has completed date (K4) 12/08/2021 but also U4 as 10/10/2024 so should say 'Pending' not 'Compliant'
      • djclements's avatar
        djclements
        Silver Contributor

        SGeorgie One last suggestion... make sure your Calculation Options are set to Automatic, or press F9 on your keyboard to recalculate the entire workbook. The most likely reason you're getting incorrect results is that your Calculation Options are set to Manual.

    • SGeorgie's avatar
      SGeorgie
      Brass Contributor
      it is still not bringing back any Expired

      I have 03/06/2021 in the completed column only and its bringing back Complaint


  • mathetes's avatar
    mathetes
    Silver Contributor

    SGeorgie 

     

    I started to try to create a spreadsheet to write and test a formula for you, but realized I don't fully understand the various possible conditions. For one thing, it's not clear whether one can expect that either:

    • all three cells (L4, P4 and V4) will be blank, OR
    • any one of the three cells, but only one of them, will have a value, OR
    • some combination of two OR three of the cells can have a value

     

    In the first case--where they're all blank--it's clear that "Not completed" is the desired result, but it's not clear (to me at any rate), what we're dealing with beyond that. How many of the cells will have a value: only one, any two, all three? 

     

    Could you please clarify. If possible, describe the setting, what the context is.

     

    AND, ideally, since you're clearly working with an existing spreadsheet, would you be able to post a copy of that actual spreadsheet along with your explanation, putting it on OneDrive or GoogleDrive, with a link pasted here that grants access to it. Not an image, an actual working spreadsheet.

    • SGeorgie's avatar
      SGeorgie
      Brass Contributor

      mathetes 

       

      Apologies I cannot attach the excel as 

       

      Here are all scenarios

      ALL Expiry Date columns BLANK - this should say 'Not Completed'

       

      Only Completed expiry date completed (in future) - this should say 'Compliant'

       

      Only Completed expiry date completed (in past) - this should say 'Expired'

       

      Pending and Pending Pending Approval with future date - this should say 'Compliant' -

       

       

      This has both Completed and Pending - dates in future - should say 'compliant'

      if Completed date were in past but Pending in future it should still say 'Compliant' 

       

       

       

      You will not see Complete (past) and pending/pending approval (past)

       

       

      That is all the scenarios i can see

       

    • SGeorgie's avatar
      SGeorgie
      Brass Contributor
      screenshot is attached as quite sensitive info
    • SGeorgie's avatar
      SGeorgie
      Brass Contributor
      Hi, so in my data we have a completed date column
      a pending date column
      and a pending approval date column

      if ALL three are blank i'd like the formula to produce 'Not Completed'

      If there is only a Completed date but its expired the formula should show expired

      if there is either a pending or pending approval date in the future it should say pending
      if either of these dates are in the past it should say expired

      • mathetes's avatar
        mathetes
        Silver Contributor

        SGeorgie 

         

        Your answer doesn't seem to cover all the possibilities. You have to realize, that you, since you're IN the situation, consider the answer to the following question is obvious and therefore not worth stating.

         

        This is a question I would be asking if we were sitting down face to face, and I apologize if it seems so obvious to you:

         

        Is it ever the case that two or more of the cells L4, P4 and V4 will have values in them?

        I understand what happens if any one of them has a value, but to me it's not clear whether two or more might have a value and what happens then if those values are inconsistent.

         

        And since that still needs answering, let me pose another, which gets at the basic design.

        In your most recent post you referred to those cells by labels (perhaps a column heading) and those labels themselves are

        • Completed
        • Pending
        • Pending Approval

        meaning that whoever is entering the data needs to pick a column that corresponds to the state of pending or completion--in other words., that entry already presumes the answer to the question this IF function is proposing to answer--so WHY do you even need a formula that answers the question??!!

         

        That is a serious question.That's a big part of why I asked before if it is possible for you to post a copy of the spreadsheet itself. Especially since two of the cells apparently are going to contain dates that reflect--or appear to reflect--almost identical data: "Pending" and "Pending Approval"   It just sounds like a confusing design, and part of what NikolinoDE and I (and others on this site) offer is help in making sure spreadsheet designs make sense, not just that formulas work.

  • NikolinoDE's avatar
    NikolinoDE
    Platinum Contributor

    SGeorgie 

    It seems like you want to check multiple conditions using the IF function to determine different statuses ('Completed', 'Pending', or 'Not Completed') based on various date columns (L, P, and V).

    Your current formula is close, but it might need some adjustments to cater to all the conditions you mentioned. Try this updated formula:

    =IF(L4>TODAY(), "Completed", IF(AND(P4>TODAY(), V4>TODAY()), "Pending", "Not Completed"))

    This formula checks:

    • If the date in column L is in the future compared to today, it returns "Completed".
    • If both P4 and V4 are in the future compared to today, it returns "Pending".
    • If none of the conditions are met, it returns "Not Completed".

    This formula assumes that if P4 or V4 is in the future, it is "Pending". Adjust the logic if both shouldn't be considered as "Pending" simultaneously. The text was created with the help of AI.

     

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

     

    Was the answer useful? Mark as best response and like it!

    This will help all forum participants.

    • SGeorgie's avatar
      SGeorgie
      Brass Contributor
      Thanks nearly there
      So scenarios are:
      Completed - If there is only a completed date in the future
      Not Completed - if L4, P4 and V4 ALL blank
      Pending - If P4 or V4 in future
      Expired - if L4 or P4/V4 in past

      This formula needs to include Expired and if L4 blank but P4 future should say Pending - see example

      I would also need to include somehow if L4 is in the past it brings back 'Expired' too?

      • OliverScheurich's avatar
        OliverScheurich
        Gold Contributor

        SGeorgie 

        =IF(AND(L4>TODAY(),N4>TODAY(),P4>TODAY()),"Completed",
        IF(OR(P4>TODAY(),V4>TODAY()),"Pending",
        IF(AND(ISBLANK(L4),ISBLANK(N4),ISBLANK(V4)),"Not Completed",
        IF(OR(L4<TODAY(),AND(P4<TODAY(),V4<TODAY())),"Expired",""))))

         

        Does this return the intended result?

         

         

Resources