How to aggregate data with different senario in custom record field

I want to add a custom record field to a record, this field should calculate a count with related record A when isActive=true and calculate a count with related record B when isActive=false.

How should I do? And how do I reference to other field(eg. isActive) in current record when writing expression for custom record field?

  Discussion posts and replies are publicly visible