sometimes the script editor tells you there's an error in set analysis when there isn't. Try your expression vSetPreviousNMonth with various values written in place of the $1 parameter as a way to test. To my eyes your expression looks okay.
I see no added value in using the variable with parameter as opposed to using it directly in the expression. The various $ expansions and the moments that they are evaluated make it very tricky. Directly in the expression:
Sorry guys this was an error on my part, the Set expression was working but the relationship between the Master Calendar and the Fact Table within the data model was non-existent, therefore the calculations returned 0 at every turn, although I do appreciate the answers provided, I had to look at the data model for a good 30m to figure this out (The answer was to create a primary key between both tables from common fields in both tables), thanks for the help non the less.