I would go for onchange nanoflow on each ref selector and a helper attribute on the dataview entity.
In each onchange check if that specific association != empty and +1 the helper attribute. If it is empty -1 (and off course don't go lower than 0)
This would mean a nanoflow per association, so maintainability is a bit lacking, but in the performance area on par I would reckon.