1

I'm trying to create a workflow to set a Customer Tier (Text) to "A", "B" or "C" depending on the number of employee. The logic should be:

  • C = 1-250
  • B = 251-500
  • A = 501+

The result is right for tier C but everything is incorrect. Can someone spot my error within this logic? The formula compiled without error.

If( NumberOfEmployees <=250, "C",if( 251 >= NumberOfEmployees &&  NumberOfEmployees  <= 500, "B", If( NumberOfEmployees < 500, "A", "None") ))

4 Answers 4

4

You can actually do this nice and neat with just two IF functions since you don't have any gaps in your ranges:

IF(NumberOfEmployees <= 250, 'C',
 IF(NumberOfEmployees <= 500, 'B', 'A'))
3
  • 1
    I thought that as well, I just didn't know if the poster wanted 'A' to be there if NumberOfEmployees was null. Sep 19, 2014 at 0:10
  • 1
    That would depend on the formula field option around nulls and blanks. In this case you'd want that set to zero I'd suspect.
    – Matt Lacey
    Sep 19, 2014 at 1:15
  • Good point, my bad, its getting late here....lol Sep 19, 2014 at 1:21
2

251 >= NumberOfEmployee must be 251 <= NumberOfEmployees

AND

NumberOfEmployees < 500 must be NumberOfEmployees > 500

1

You have the syntax correct, you just have some of your operators a bit mixed up. Just need to switch some of your Greater Than's (>), to Less Than's (<), and vice-versa.

This should work

IF(
     NumberOfEmployees <=250, 
     "C",
     IF(
          NumberOfEmployees >= 251 && NumberOfEmployees <= 500,
          "B",
          IF(
               NumberOfEmployees > 500,
               "A", 
               "None"
          )
     )
)
0
0

here's a slightly altered formula which you can try

If( NumberOfEmployees <=250, "C",
    if( NumberOfEmployees >= 251 && NumberOfEmployees <= 500, "B", 
        If( NumberOfEmployees > 500, "A", "None") 
    )
)

also, if believe you can make this Customer Tier as a formula text field and directly use this formula in the field itself instead of a Workflow Rule + Field update (unless you want the field to be editable)

2
  • But make the formula shorter: IF(ISNULL(NumberOfEmployees),"None", IF(NumberOfEmployees < 251, "C", If(NumberOfEmployees < 501, "B", "A"))) Remember that the compiled size is limited, so taking out the extra bit will reduce the compiled size a bit.
    – sfdcfox
    Sep 19, 2014 at 3:02
  • there's always a room for optimisations :-) and I prefer using ISBLANK instead of ISNULL Sep 19, 2014 at 3:53

You must log in to answer this question.

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