What do you mean by it throws an error? An error in editor? if you put set analysis expression in variable e.g. vSetMTD sometimes the expression editor shows error but it works
try making the entire set as 1 variable. you will get a error message in editor but it works e.g. count({<$(vSetAnalysis)>}Flags)