# New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
QlikWorld May 10-12, Online and Free! REGISTER NOW
cancel
Showing results for
Did you mean:
Creator II

## Current month previous year expression

Hi guys,

I want to compare the sales of the current month in the current year with the sales in the current month in the previous year.

I tried the following expressions:

 sum({< Year={"\$(=max({}Year)-1)"}, Date ={">=\$(=MonthStart(Today())) <=\$(=MonthEnd(Today()))"} >}[Nett Amount new EUR]) sum({< Year={"\$(=max({}Year)-1)"}, Date ={">=\$(=MonthStart(Today()-12)) <=\$(=MonthEnd(Today()-12))"} >}[Nett Amount new EUR])

The Year (current year) and Date (current month) are working seperately, but not when combined.

It would be great if you guys could help me out!

Cheers:)

Mike

1 Solution

Accepted Solutions
Partner

Try this for previous year current month

9 Replies
Partner

Why do you want to combine it..

You can simply get it with Date.

Creator II
Author

Because when I use only the Date expression, I get the sales of the current year instead of the previous year..

Any idea why that happens and how to solve it?

Note:

This is the Date expression I use

 sum({< Date ={">=\$(=MonthStart(Today()-12)) <=\$(=MonthEnd(Today()-12))"} >}[Nett Amount new EUR])
Creator II

Hi Mike,

Do you have MonthYear in your Calendar Table?

If so you could use this set analysis for Current Month of current year:

{<MonthYear = {">=\$(=Date(Max(MonthYear), 'MMM-YYYY'))<=\$(=Date(Max(MonthYear), 'MMM-YYYY'))"}>}

and this for current month of previous year:

Regards,

Sílvia

Creator II
Author

Hi Sivia,

thanks a lot for your reply and your effort! I do have the MonthYear in my Calendar Table.

Unfortunately, the current year shows a revenue of 0 and the previous year shows an amount which is waaaaaay too big..

The latest expression I've tried is:

Strange enough I get some similar revenues and some slighlty different revenues compared to the simple expression below.

 Sum ({\$}[Nett Amount new EUR])

So I'm still trying to find a proper expression haha

Regards,

Mike

Partner

Try this for previous year current month

Creator II
Author

Yeah that works perfectly! Thanks a lot Shraddha

For my understanding.. The main change is in the (date(addmonths(...))-12) you've added isn't it?

Partner

Yes correct..

Contributor

Have similar question...

Have you suggestion how to modify below expression to get full previous month of current year?

Regards

Jacek

Creator II
Author

Hi Jacek,

to get the full previous month of current year, I think you just have to change the '-12' into '-1'.

So the expression will look like this: