Please check the comment: Adding Filters in Query Report - #2 by NCP
Reference: Adding Filters in Query Report - #4 by NCP