Assistance with Custom Formula (to Aggregate Data)

Hello, Can someone assist me with a formula?

Within custom reports, I’m trying to aggregate 3 role types into 1. If, in the report, a contact is identified as a teahcer PK-5, teacher 6-12, or teacher on special assignment, I want those contacts to be aggregated in one bar of data to show me the total number of contacts with any of those roles.

This first section of the formula is correct and wokring corrrectly:

(COUNT(IF([CONTACT.role_drop_down] = “Teacher PK-5”, 1, NULL)))

however, I want to count 2 additional roles, but the formula below returns errors.

(COUNT(IF([CONTACT.role_drop_down] = “Teacher PK-5”, 1, NULL),([CONTACT.role_drop_down] = “Teacher 6-12”, 1, NULL),([CONTACT.role_drop_down] = “TOSA”, 1, NULL)))

Can anyone assist me with this?

Thanks in advance!

Hey @JGrayson6 - thanks so much for posting in the Community!
I’d like to tag in some experts here to get some insight on how to better structure this formula. @HubSpot_Corey, @ScottPennwood, and @JessicaBaskey - any thoughts here?
Shane, Senior Community Moderator

Hi @JGrayson6
The following formula:
COUNT(IF([CONTACT.role_drop_down] = “Teacher PK-5” OR [CONTACT.role_drop_down] = “Teacher 6-12” OR [CONTACT.role_drop_down] = “TOSA”, 1, NULL))
should do the trick :slightly_smiling_face:

thank you so much! I just tried implementing your solution as a custom formula, but it seems to only be pulling data from 1 of the “teacher” roles as opposed to all 3. I am hoping to come up with a formula where the sum of the 3 teacher roles is 984. I tried a similar “sum” formula (see below), but neither are adding all 3 teacher roles into 1 number. These roles are exclusive and one contact can have more than 1 role.

*note: I changed “TOSA” to teacher on special assignment to match the HubSpot property. Any thoughts?

SUM(IF([CONTACT.role_drop_down] = “Teacher PK-5”, 1, 0) + IF([CONTACT.role_drop_down] = “Teacher 6-12”, 1, 0) + IF([CONTACT.role_drop_down] = “Teacher on special assignment”, 1, 0))

This is a screenshot of the report before the customer formula, showing the 3 teacher properties I am trying to aggregate.

And this is the result of the custom formula. It looks like it’s only pulling in Teacher 6-12 data.

Appreciate your help!

Jenny

@JGrayson6

It works on my end with that formula. Alternatively, you can also apply a filter on that property to achieve the same result.

Just to clarify, you’re looking to aggregate the count of those three roles and display the total, correct?

Correct, I’m trying to aggregate the count of the 3 roles and display the total.

Hmmm, I will have to look into this. Perhaps there’s something wrong with the titles I’m using. I appreciate your help! Let me try again, and I’ll keep you updated.

@d-lupo Got it! I was using the property label instead of the internal name for the property. Problem solved, thank you!

Happy to help :grinning_face_with_smiling_eyes: