Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
mossandon
Contributor II
Contributor II

Previous three months

Hi friends,

I need to show sales for the three previous months to the selected month,

In the example show a month earlier, but do not know how to show the other two previous months.

I appreciate your help.

Thx in advance

1 Solution

Accepted Solutions
sunny_talwar

Here you go. Back to straight table with 4 expressions and 1 dimension:

Capture.PNG

Expressions

1) sum({$<Year, Month, Date = {"$(='>=' & Date(MonthStart(Max(Date))) & '<=' & Date(MonthEnd(Max(Date))))"}>} Sales)

2) sum({$<Year, Month, Date = {"$(='>=' & Date(MonthStart(Max(Date), -1)) & '<=' & Date(MonthEnd(Max(Date), -1)))"}>} Sales)

3) sum({$<Year, Month, Date = {"$(='>=' & Date(MonthStart(Max(Date), -2)) & '<=' & Date(MonthEnd(Max(Date), -2)))"}>} Sales)

4) sum({$<Year, Month, Date = {"$(='>=' & Date(MonthStart(Max(Date), -3)) & '<=' & Date(MonthEnd(Max(Date), -3)))"}>} Sales)

View solution in original post

13 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

HI,

Try this

Sum({<Date = {">=$(=monthstart(addmonths(Max(Date),-1)))=$(=Monthend(addmonths(Max(Date),-1)))"},Year=,Month=>}Sales)

For previous month

Sum({<Date = {">=$(=monthstart(addmonths(Max(Date),-2)))<=$(=Monthend(addmonths(Max(Date),-2)))"},Year=,Month=>}Sales)

For Previous to Previous Month and so on.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
sunny_talwar

May be this:

Converted your table into a pivot table

Capture.PNG

mossandon
Contributor II
Contributor II
Author

Thx Sunny T,

It works ok, but I need to use other dimensions than the month...I forget to add

I incorporated new dimension called "Region" in the attached example.

you could help me with that dimension?

sunny_talwar

Is this the kind of table you envision?

Capture.PNG

mossandon
Contributor II
Contributor II
Author

Yes, but the dimension must only be "Region" no "MonthYear".

It is possible?

mossandon
Contributor II
Contributor II
Author

Many Thx Kaushik,

But I get an erroneous result by applying the expression, and is independent of the selection.

QV_expresion1.PNG

sunny_talwar

You don't want to see MonthYear? Like this?

Capture.PNG

erjohnso
Creator
Creator

You can also potentitally use the max(fieldname, rank) function in your set analysis.

For example, max(Month, 2) would give you the "prior" month if the current month is the max month. max(Month, 3) and max(Month, 4) would be the 2 and 3 months back from current.

mossandon
Contributor II
Contributor II
Author

Yes I need to see the month year but not included as used dimension:QV_expresion2.PNG