Hi Cornelia!
Thank you so much for your helpful response!
Sorry for silence, but I had to switch over to other tasks and didn't have time to try out the approach recommended by you. I'm returning to this report and will let you know when I get results (to be honest, I've never used a variable replaced by a query before).
Best regards,
Evgeniya