I have fixed the dropdown in the report by resource and adjusted the script to work based on the required output. I have tested the script and it is now functioning correctly, producing the desired results.