I found the answer in an earlier post (https://www.mathworks.com/matlabcentral/answers/418060-count-unique-id-occurrences-in-a-column-after-grouping-based-on-another-column)
name = {'A', 'A', 'A', 'B', 'B', 'B', 'C', 'C', 'C'}.';
type = {'AA', 'BB', 'CC', 'BB', 'BB', 'BB', 'AA', 'CC', 'CC'}.';
t = table(name, type);
n_type = rowfun(@(v) numel(unique(v)), t, 'GroupingVariables', 'name', 'InputVariables', 'type')