Add filter before applying groups