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: 
sarasunagaram
Partner - Contributor II
Partner - Contributor II

sum of sales for past 3 months for selected date

Hi,

I am trying to get sum of sales for past 3 months for selected date.

but in my expression AddMonths() is not working properly.

sum({$<RPT_DT={">=$(=Addmonths(RPT_DT,-3)) <$(=RPT_DT)" }>}Sales)

Here Report date is in Timestamp format  like 7/1/2014 12:00:00 AM 

I am using below expression also. but i didn't get

sum({$<RPT_DT={">=$(=Addmonths(=Date(RPT_DT,'MM/DD/YYYY'),-3)) <$(=RPT_DT)" }>}Sales)

Here I am getting data for  all the previous months for selected date  for both expressions but i want only for past 3 months

can anyone  help me

Thanks in Advance.

Muni

3 Replies
vikasmahajan

create month field in calendar and see this link

https://community.qlik.com/message/36589#36589

Vikas


Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
ahammadshafi
Creator
Creator

Hi Muni:

Can you please try the following expression

sum({$<RPT_DT={">=$(=Addmonths(Max(RPT_DT),-3)) <$(=Max(RPT_DT))" }>}Sales)

Ahammad Shafi

Kushal_Chawda

First Convert the Report Date to date format without time in script like below

Data:

LOAD *,

           Report_Date,

            date(floor(Report_Date),'DD-MM-YYYY') as Date

FROM table

Now use below expression

sum({$<Date={">=$(=Addmonths(max(Date),-3)) <=$(=max(Date))"}>}Sales)