Try this expression
= count(DISTINCT aggr(count( if(document<>'document2', branch)),branch))
removed DISTINCT inside aggr, just try it.
Pls. see attachement
A Straight Table with :
Will give the count of ranches for each document.
You can select document2 if that is the only one you wish to see.
May be like this,
Hope this helps,
try this Expression for Branches that do not have Document 2
= count(DISTINCT aggr(count(DISTINCT if(document<>'document2', branch)),branch))
Please find the attachment