my two cents...you can use (some) summaries for group select.
If i understand you correctly you just want to exclude a group if the sum of the amount for that account=0. (Your sample data already shows pos and neg values related to the XXX or YYY rows with no other row types).
if that is correct you can exlcude the group using the select expert set for group criteria with
NOT(sum(amount,account)=0)
if you have other rows in the grouping (account) that are not xxx or yyy that you want to ignore for your zero sum check you would ned to add another formula similar to kostya's suggestion and sum that
//groupchecker
if field in ['xxx','yyy'] then amount
then use that in the group select
NOT(sum(@groupchecker,account)=0)
if you also have to validate that there are the same number of xxx rows as yyy rows that can also be added