I managed to reproduce this error (in 9.11.0). This is definitely a Mendix-Studio-bug in the loop. If you copy-paste the Create Dashboard to after the loop, this will not give an error. Another attept showed me that you also do not get an error if you break it up in two steps.
So the workaround is to, in the loop, break the create-activity up in two steps:
The variable in the loop is called $Count but you are using $Counter in the if / else expression.