简体   繁体   中英

Excel 2010: Nested IF statement

I have been working on created a nested IF for a document I am working on, however I have maneged to make two diffrent IF statemnets that both work but they need to be merged.

The infomation its in relation to is:

      J           K          L          M        N
23  Start        End                           Cloud
24  01/04/2014             cloud                Yes
25  03/03/2014             Overdue      
26  22/05/1992             cloud                Yes
27  03/03/2014             Overdue      
28  01/07/2014             cloud                Yes
29  29/06/2014             On Time      
30  03/03/2014  10/03/2014 Complete              Yes

The two IF's i current have are:

This If statement firstly looks to see if the End column is filled if it is filled then the project is completed and that can be Displayed in column L. Then it takes the start(date) in ciolumn J and adds 10 workdays it then compares this to todays date to see if the project is Overdue or ontime.

=IF(NOT(ISBLANK(K25)),"Complete",IF(WORKDAY(J25,10)<TODAY(),"Overdue","On Time"))

This IF statement looks to see if there is a Yes in the Cloud collumn(N) if there is it then adds 20 working days to the start date then compares that to todays date to see if the project is overdue or on time.

=IF(AND(N26 = "Yes", (WORKDAY(J26,20)<TODAY())),"Overdue", "On Time")

So what I am looking for is these two combined but i always get an error or a emssage saying to many arguments.

What it needs to do is: 1) look to see if their is and end date if there is set column L to complete 2) see if there is a Yes in the cloud collumn if so add 20 workdays to the start date the compare to todays date and set column L to either overdue or on time 3) if the cloud column is empty add 10 workdays to the start date then compare to todays date and set column L to either overdue or ontime.

Any help would be awesome!!!

The problem with your combined formula is simple. When doing complex IF statements in Excel, I find that it can help to nest them with tabs

=IF(NOT(ISBLANK(K26)),
  "Complete",
IF(AND(N26 = "Yes", (WORKDAY(J26,20)<TODAY())),
  "Overdue",
"On Time",
IF(WORKDAY(J26,10)<TODAY(),"Overdue","On Time")))

With Excel IF statements, in order to nest them successfully, they have to be in a pattern of IF(Condition,Value,Else IF) . You'll notice that your second IF statement goes IF(Condition,Value1,Value2,Else IF) . Obviously this does not work because IF can only take 2 arguments. It appears that you have two scenarios to handle if Cloud = Yes , so we need to take more care in our nesting. One way to do this would be to not use the conditional AND and nest an IF statement in our first value position.

=IF(NOT(ISBLANK(K26)),
   "Complete",
 IF(N26 = "Yes",                    
   IF(WORKDAY(J26,20)<TODAY(),      
     "Overdue",
     "On Time"),
 IF(WORKDAY(J26,10)<TODAY(),
     "Overdue",
     "On Time")))

In the second major IF , we've grouped all of the logic for Cloud = "YES under on IF statement. Then if that's not true, we perform the basic 10 day check. Here is the completed formula in non-nested form. Let me know if I misunderstood anything.

=IF(NOT(ISBLANK(K26)),"Complete",IF(N26 = "Yes",IF(WORKDAY(J26,20)<TODAY(),"Overdue","On Time"),IF(WORKDAY(J26,10)<TODAY(),"Overdue","On Time")))

I switched the dates around to M/D/Y for my own clarity and these were my results with the formula based on today's date (July 11, 2014).

4/1/2014                Overdue         Yes
3/3/2014                Overdue     
5/22/1992               Overdue         Yes
3/3/2014                Overdue     
7/1/2014                On Time         Yes
6/29/2014               On Time     
3/3/2014    10/3/2014   Complete        Yes

EDIT: Table Formulas

Here is the formula above in Table format with the following headers/columns

Start       End         Status      Cloud
4/1/2014                Overdue     Yes
3/3/2014                Overdue 
5/22/1992               Overdue     Yes
3/3/2014                Overdue 
7/1/2014                On Time     Yes
6/29/2014               On Time 
3/3/2014    10/3/2014   Complete    Yes

Formula

=IF(NOT(ISBLANK([@End])),"Complete",IF([@Cloud] = "Yes",IF(WORKDAY([@Start],20)<TODAY(),"Overdue","On Time"),IF(WORKDAY([@Start],10)<TODAY(),"Overdue","On Time")))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM