I’m not sure you really are counting as it doesn’t seem like your example will ever give you anything other than a 0 or a 1. It seems you just want to know if Mary has attended any courses in the Absence category or not.
Would a formula checking if there is an Absence category course work for you? A formula like:
IF(FIND('Absence', Category), 1, 0)
will check for the Absence category and give you either a 1 or a 0.
If I misunderstood and what you want to do is count all unique categories, then you can do a Rollover for the Categories table and use this in the aggregation formula:
and it will return a count of all unique categories.