You need to sign in to do that
Don't have an account?
Chris McCoy 6
If statement with two variables and Case function.
I'm new to Salesforce and I am trying to create a formula that will look at two variables and determine a cost percentage.
Field 1 is a status (picklist) and Field2 is either null or Available(picklist). For Statuses PROC & UNCO the second variable isn't needed - only for the EXIS status. The cost percentage is then based on either the one variable or the combination and I used CASE function to determine the percentage that goes into Field3.
The formula works great for anything in PROC or UNCO status - but nothing happens if it is in EXIS status. Any suggestions will be greatly appreciated.
IF( ISPICKVAL(Account.Field1_Status_NA__c, "PROC") ,
CASE(Account.Field3_NA__c,"A", 15/100,"B",20/100,"C",20/100,"D",20/100,"E",25/100, "F",25/100,"G", 30/100,0),
IF(ISPICKVAL(Account.Field1_Status_NA__c, "UNCO") ,
CASE(Account.Field3_NA__c,"A", 15/100,"B",20/100,"C",20/100,"D",20/100,"E",25/100, "F",25/100,"G", 30/100,0),
IF(AND(ISPICKVAL(Account.Field1_Status_NA__c, "EXIS") , ISPICKVAL( Account.Field2__c, " ")) ,
CASE(Account.Field3_NA__c,"A", 10/100 ,"B",15/100, "C",15/100,"D",15/100,"E",25/100, "F",25/100,"G", 0,0),
IF(AND(ISPICKVAL(Account.Field1_Status_NA__c,"EXIS"), ISPICKVAL( Account.Field2__c, "Available" )),
CASE(Account.Field3_NA__c,"A", 5/100,"B",10/100,"C",10/100,"D",10/100,"E",15/100, "F",15/100,"G",0, 0), Null) ) ) )
Field 1 is a status (picklist) and Field2 is either null or Available(picklist). For Statuses PROC & UNCO the second variable isn't needed - only for the EXIS status. The cost percentage is then based on either the one variable or the combination and I used CASE function to determine the percentage that goes into Field3.
The formula works great for anything in PROC or UNCO status - but nothing happens if it is in EXIS status. Any suggestions will be greatly appreciated.
IF( ISPICKVAL(Account.Field1_Status_NA__c, "PROC") ,
CASE(Account.Field3_NA__c,"A", 15/100,"B",20/100,"C",20/100,"D",20/100,"E",25/100, "F",25/100,"G", 30/100,0),
IF(ISPICKVAL(Account.Field1_Status_NA__c, "UNCO") ,
CASE(Account.Field3_NA__c,"A", 15/100,"B",20/100,"C",20/100,"D",20/100,"E",25/100, "F",25/100,"G", 30/100,0),
IF(AND(ISPICKVAL(Account.Field1_Status_NA__c, "EXIS") , ISPICKVAL( Account.Field2__c, " ")) ,
CASE(Account.Field3_NA__c,"A", 10/100 ,"B",15/100, "C",15/100,"D",15/100,"E",25/100, "F",25/100,"G", 0,0),
IF(AND(ISPICKVAL(Account.Field1_Status_NA__c,"EXIS"), ISPICKVAL( Account.Field2__c, "Available" )),
CASE(Account.Field3_NA__c,"A", 5/100,"B",10/100,"C",10/100,"D",10/100,"E",15/100, "F",15/100,"G",0, 0), Null) ) ) )
All Answers
But that doesn't explain why the Available doesn't work.
IF(OR(ISPICKVAL(Account.Field1_Status_NA__c, "UNCO"), ISPICKVAL(Account.Field1_Status_NA__c, "PROC") ),
CASE(Account.Field3_NA__c,"A", 15/100,"B",20/100,"C",20/100,"D",20/100,"E",25/100, "F",25/100,"G", 30/100,0),
IF(AND(ISPICKVAL(Account.Field1_Status_NA__c, "EXIS") , ISBLANK( Account.Field2__c)) ,
CASE(Account.Field3_NA__c,"A", 10/100 ,"B",15/100, "C",15/100,"D",15/100,"E",25/100, "F",25/100,"G", 0,0),
IF(AND(ISPICKVAL(Account.Field1_Status_NA__c,"EXIS"), ISPICKVAL( Account.Field2__c, "Available" )),
CASE(Account.Field3_NA__c,"A", 5/100,"B",10/100,"C",10/100,"D",10/100,"E",15/100, "F",15/100,"G",0, 0), Null) ) ) )
Use ISBLANK() istead of ISPICKVAL, that's what you're looking for, unless you have a picklist option whose value is one space.
Also, the values inside the case function were the same if your picklist was UNCO or PROC, so I shortened the formula a little for you.
Hope this helps,
Parker
Thanks for posting your question,
Parker