You need to sign in to do that

Don't have an account?

George Adams

# Creating basic formula field (Incorrect number of parameters for function 'IF()')

Hello,

I have what I think is a simple question. I am trying to do the following:

There's a good chance I'm making a simple mistake here, just can't seem to find it.

Thanks!

I have what I think is a simple question. I am trying to do the following:

- Have the formula look at MK_Days_When_Postmarked__c
- If it is blank, run throught the 4 calculations regarding trial date messages
- If it is not blank, run TEXT(MK_Days_When_Postmarked__c) (ie. show the number in that field)

IF( ISNULL(MK_Days_When_Postmarked__c), IF( MK_Days_Into_Trial__c = 0 , "Not Yet Shipped" , IF( MK_Days_Into_Trial__c < 46 , "Day " + TEXT(MK_Days_Into_Trial__c) , IF( MK_Days_Into_Trial__c < 51 , "Manually Calculate (~" + TEXT(MK_Days_Into_Trial__c) +" Days)" , IF( MK_Days_Into_Trial__c > 50 ,"Out of Trial (" + TEXT(MK_Days_Into_Trial__c) + " Days)", TEXT(MK_Days_When_Postmarked__c) ) ) ) ) )

There's a good chance I'm making a simple mistake here, just can't seem to find it.

Thanks!

R Z KhanOh i see. then the formula should be as following

## All Answers

R Z KhanHi Mathew,

seems like your outermost If statement has only 2 parameters. If statement should be IF(condition, ifTrue, ifFalse)

George AdamsThanks for the reply.

My understanding is that my formula is setup as IF( ISNULL(MK_Days_When_Postmarked__c), [all the statements about trial date], [just show what's in MK_Days_When_Postmarked__c]).

Is that not the way I've written it?

R Z KhanNo, the formula is if(ISNULL(

MK_Days_When_Postmarked__c

), [all statements])

TEXT(MK_Days_When_Postmarked__c) belongs to the last inner IF statement. not to the outermost statement.

George AdamsI understand what you're saying, but when I modify the code to add a final ifFalse statement, I still get the error but is says I'm giving it too many parameters.

Expected 3, received 4.

R Z Khanno,

it hsoudl be before the last ')'

George AdamsAwesome, thank you. That works (after removing that extra comma).

Can you reverse the ifTrue and ifFalse conditions on the outermost IF?

I can't seem to get it working. As in, if ISNULL(MK_Days_When_Postmarked__c) is true, then just run all the IFs, but if not, just run TEXT(MK_Days_When_Postmarked__c).

I reversed the order by accident.

R Z KhanHi Mathew,

you can do it by replacing "text" with TEXT(MK_Days_When_Postmarked__c). But what did you want ot do in the innermsot IF statemebnt. whats suppsoed to happen if MK_Days_Into_Trial__c<=50?

George AdamsIf MK_Days_Into_Trial__c <= 50, isn't that covered by the following (and all the previous statements?):

George AdamsRight now the forumla is just returning 0. R Z KhanOh i see. then the formula should be as following

R Z KhanRight nwo this is how your formula works

If (MK_Days_When_Postmarked__c is null) then

if(MK_Days_Into_Trial__c == 0) you return Note Yet SHipped

if(MK_Days_Into_Trial__c <46 you return "Day " + TEXT(MK_Days_Into_Trial__c)

if( MK_Days_Into_Trial__c >=51 you return "Out of Trial (" + TEXT(MK_Days_Into_Trial__c) + " Days)"

but if its >=46 AND <51 you return "Manually Calculate (~" + TEXT(MK_Days_Into_Trial__c) +" Days)"

AND if MK_Days_When_Postmarked__c is not null then return MK_Days_When_Postmarked__c

So is this correct?

George AdamsYes, that's exactly how it is supposed to work. Problem is the formula you most recently made is returning 0 in the field.

If I change MK_Days_When_Postmarked__c to any number, however, it returns that number. So it does look like it's copying MK_Days_When_Postmarked__c BUT when that field is blank, it seems to think it's not blank.

R Z Khantry changing ISNULL(MK_Days_When_Postmarked__c) to ISNULL(MK_Days_When_Postmarked__c) || MK_Days_When_Postmarked__c=0 George AdamsAwesome! Thank you so much. That works perfectly.