you need to sumamrize across rows
the easiest way is convert your values into 1 or 0 and then sum that.
I am assuming you have it in a grouping and are placing this in a group footer. This will also work in a group header
here is an sample for you 'ab' column called AB_flag
if {table.field}='AB' then 1 else 0
sum this at the group level
sum(@AB_flag,table.groupfield)
this will give you a 0 if there were no ABs and any value >0 if there were
you can use that result to create text or color or whatever