Date function fro calculated field - items added last month

Hi all,
I’m currently tackling below exercise within QS. As per sample data below, i want to create a calculate filed which counts only those items created as per previous month (at the time of running report). I’m able to do this by applying the filter but i’d prefer to calculate it by qs function. Is there any way to achieve this?

Thanks in advance.

image

I think this calculated field will work for you.

countOver(ifelse(truncDate('MM',{date})=addDateTime(-1,'MM',truncDate('MM',now())),{id},NULL),[],PRE_AGG)

Thanks @Max let me try this out.

1 Like

@Max it’s working fine with

distinct_countIf (id, truncDate('MM',{date}) = addDateTime(-1,'MM',truncDate('MM',now())) )

Thanks for helping out with addDateTime function.