I resolved the issue before posting, but would still like to share, in case anybody else has the same issue in the future. May the google algorithms be with you.
I followed this blog by Gregor, and implemented the counting of records in a similar way.
BUT I added the annotaion @UI.Hidden
which caused my dummy field to be excluded. Removing the annotation caused the issue to be resolved.