Aggregate on boolean field?

  • 1
  • Question
  • Updated 3 years ago
I keep getting errors like this:
Error:field Appointment_Scheduled__c does not support aggregate operator SUM

Where Appointment_Scheduled__c is a boolean.
Same error with COUNT or AVG.

What is the best way to count the number of times that a boolean is true in an aggregate model?

Thanks!
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
You want to group the boolean field and then aggregate on some other field,  maybe an ID (COUNT). 

If you really only want to know how many times the boolean is true -  (And don't care about the false) - then put the boolean field in a condition and aggregate on ID as above. 
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Hmm. Ok.

I want to group on a different field (a picklist), and then count how many times the boolean is true for records in each picklist category. I was hoping to re-use a model that I already have to count total records, but it looks like I'll have to create a new model with a boolean = true condition to count those.