Standard deviation on N rolling months

Are you looking to divide it just by the amount of months you have filtered? If so you can do something like this.

sumOver(count({session_id}))/avg(distinctCountOver(truncDate(‘MM’,{event_timestamp}),[],PRE_AGG))

This will take the distinct count of months that is selected.

Let me know if that is what you are looking for