3

I have a checkbox and picklist field.I want to have a formula field which evaluates that the checkbox is checked and will assign different values based on user selected picklist field value.

Here is my formula:

(IF(Cognos_BI_Access_Required__c,
    IF(
        OR(
            ISPICKVAL(Project__c, "ITS"),
            ISPICKVAL(Project__c, "Tax Dashboard"),
            ISPICKVAL(Project__c, "VEASI")
        ),
        "ITS Developers/ITS report testers",
        "Corporate Tax",
        "CR_VEASI_USERS"
    ),
    None)
)

But I am getting the below error :

Error: Incorrect number of parameters for function 'IF()'. Expected 3, received 4

Any suggestions?

0

2 Answers 2

3

I believe you're actually looking for CASE, which allows you to map one value to another. Your formula should probably look like this:

IF(Cognos_BI_Access_Required__c,
    CASE(TEXT(Project__c), 
        "ITS", "ITS Developers/ITS report testers",
        "Tax Dashboard", "Corporate Tax",
        "VEASI", "CR_VEASI_USERS",
        NULL),
    NULL
)
2

The syntax is:

IF(logical_test, value_if_true, value_if_false)

So for one IF statement:

IF(/*condition 1*/), "Value if true", "Value if false")

For nested IF statements:

IF(/*condition 1*/, "Value if condition 1",
    IF(/*condition 2*/, "Value if condition 2", "Value if not condition 2")
)

In the above:

  • condition 1 represents Cognos_BI_Access_Required__c
  • condition 2 represents your OR clause
  • It is unclear based on your OP how to map the text values.

If you are trying to specify an if/else chain for one field CASE is the appropriate mechanism, as also mentioned by @sfdcfox. The syntax is:

CASE(expression,​value1, result1, value2,​ result2,...,​ else_result) 

Here:

  • expresion represents Project__c
  • result1 represents "ITS"
    • value1 represents "ITS Developers/ITS report testers"
  • result2 represents "Tax Dashboard"
    • value2 represents "Corporate Tax"
  • result3 represents "VEASI"
    • value3 represents "CR_VEASI_USERS"
  • You haven't really discussed, but else_result should likely be null.
1
  • Thanks @Adrian Larson!! The outer if condition will check if the checkbox Cognos_BI_Access_Required__c is checked and then the nested if statement will check Project__c is equal to ITS , then the formula field(Group__c) will return text value ITS Developers/ITS report testers... If the issue is clarified can u rectify the formula?
    – MaxPyne
    Commented Jul 14, 2016 at 21:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .