I created a number formula field that looks at the WhoId of the activity and the goal was to determine if the value was a lead or a contact so that I can do reporting on it.

This is the formula I am using, but leads are still failing the logic test. Can anyone offer some insight as to what I may be forgetting in my logic?

Thanks for your time,

IF(WhoId = LEFT("00Q",3), 1, 0)

  • What is your end goal here? Seems likely you could do away with this formula entirely.
    – Adrian Larson
    Commented Jan 14, 2019 at 22:17

2 Answers 2


You can just check Who.Type, which is much more clear syntactically.

If your field is Is_Lead__c:

Who.Type = "Lead"

If your field is Who_Type__c:


Note that in queries, you could even just pull Who.Type directly, with no need for a formula. But you might need to build it out for certain types of reporting. Since you haven't made your end goal clear in the question, I included the latter formula as well.

  • 1
    +1 , Far better and cleaner, no hardcoding Id's . Commented Jan 14, 2019 at 22:18
  • I hate to be the bearer of bad news, but Who.Type doesn't actually compile as a formula field value. It seems to work pretty much everywhere else except for this one use case.
    – sfdcfox
    Commented Jan 15, 2019 at 7:26

You have to use LEFT on WhoID and then check(==) with 00Q to see if its lead or not.

IF(LEFT(WhoId,3)=='00Q', 1, 0)

Better way would be to use switch case

Case(LEFT(WhoId , 3),'00Q','Lead','003','Contact','Other' )
  • Awesome! That did the trick! Can you help me understand the "==" instead of using an = in the first scenario that you have? Or is it the same?
    – Cameron K
    Commented Jan 14, 2019 at 22:15
  • 1
    The = and == operator are interchangeable. So same thing Commented Jan 14, 2019 at 22:16

You must log in to answer this question.

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