Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
purna
Contributor III
Contributor III

Expression to get  last 60days sales_value using addmonth

Hello Qlik'ers

 

Can any one please help me for the expression to get  last 60days sales value using addmonth

I have oct,nov,dec sales

Expression Given:

=sum({<Month={"$(=addmonth(max(Month)-2))>=$(addmonth(max(Month)))"}>}Sales)

Result:

But throwing the result for sum(sales),but i want only last 60 days value, please help me in this

Thanks in advance

Purna.

1 Solution

Accepted Solutions
Vegar
MVP
MVP

It is a typo. It should be AddMonths().  See attached qvf where I've used your sample data.

=sum({<[Date]={">=$(=addmonths(max([Date]),-2))<=$(=max([Date]))"}>}Sales)

Vegar_0-1637326109261.png

 

View solution in original post

5 Replies
Vegar
MVP
MVP

What is the content  of Month? If it is Jan, Feb, Mar,..., Dec, then you can't use it. Try my adjusted expression  below where I among other things have replaced Month with a date field Date:

=sum({<[Date]={">=$(=addmonth(max([Date]),-2))<=$(=max([Date]))"}>}Sales)

purna
Contributor III
Contributor III
Author

Thanks for the responce,but again same error result.

LOAD
"Date",
Sales,
Category 

this is my data loded.

 

 

purna
Contributor III
Contributor III
Author

Hear is my data in xl...

Date Sales Category
1-Jan-21 261.96 Furniture
2-Jan-21 731.94 Furniture
3-Jan-21 14.62 Office Supplies
4-Jan-21 957.578 Furniture
5-Jan-21 22.368 Office Supplies
6-Jan-21 48.86 Furniture
7-Jan-21 7.28 Office Supplies
8-Jan-21 907.152 Technology
9-Jan-21 18.504 Office Supplies
10-Jan-21 114.9 Office Supplies
11-Jan-21 1706.18 Furniture
12-Jan-21 911.424 Technology
13-Jan-21 15.552 Office Supplies
14-Jan-21 407.976 Office Supplies
15-Jan-21 68.81 Office Supplies
16-Jan-21 2.544 Office Supplies
17-Jan-21 665.88 Office Supplies
18-Jan-21 55.5 Office Supplies
19-Jan-21 8.56 Office Supplies
20-Jan-21 213.48 Technology
21-Jan-21 22.72 Office Supplies
22-Jan-21 19.46 Office Supplies
23-Jan-21 60.34 Office Supplies
24-Jan-21 71.372 Furniture
25-Jan-21 1044.63 Furniture
26-Jan-21 11.648 Office Supplies
27-Jan-21 90.57 Technology
28-Jan-21 3083.43 Furniture
29-Jan-21 9.618 Office Supplies
30-Jan-21 2542.23 Technology
31-Jan-21 261.96 Furniture
1-Feb-21 731.94 Furniture
2-Feb-21 124.62 Office Supplies
3-Feb-21 57.5775 Furniture
4-Feb-21 122.368 Office Supplies
5-Feb-21 48.86 Furniture
6-Feb-21 7.28 Office Supplies
7-Feb-21 907.152 Technology
8-Feb-21 128.504 Office Supplies
9-Feb-21 114.9 Office Supplies
10-Feb-21 176.184 Furniture
11-Feb-21 911.424 Technology
12-Feb-21 1235.5 Office Supplies
13-Feb-21 407.976 Office Supplies
14-Feb-21 6180.81 Office Supplies
15-Feb-21 122.54 Office Supplies
16-Feb-21 1665.88 Office Supplies
17-Feb-21 55.5 Office Supplies
18-Feb-21 258.56 Office Supplies
19-Feb-21 2013.48 Technology
20-Feb-21 22.72 Office Supplies
21-Feb-21 19.46 Office Supplies
22-Feb-21 60.34 Office Supplies
23-Feb-21 71.372 Furniture
24-Feb-21 144.63 Furniture
25-Feb-21 211.648 Office Supplies
26-Feb-21 1190.57 Technology
27-Feb-21 383.43 Furniture
28-Feb-21 109.618 Office Supplies
1-Mar-21 402.23 Technology
2-Mar-21 58 Furniture
3-Mar-21 47 Furniture
4-Mar-21 52.9 Office Supplies
5-Mar-21 587 Furniture
6-Mar-21 54.2 Office Supplies
7-Mar-21 48.86 Furniture
8-Mar-21 7.28 Office Supplies
9-Mar-21 907.152 Technology
10-Mar-21 18.504 Office Supplies
11-Mar-21 114.9 Office Supplies
12-Mar-21 1706.18 Furniture
13-Mar-21 911.424 Technology
14-Mar-21 15.552 Office Supplies
15-Mar-21 407.976 Office Supplies
16-Mar-21 68.81 Office Supplies

 

showing the result for sum(sales) with this expression  also. Any other attempt please.

=sum({<[Date]={">=$(=addmonth(max([Date]),-2))<=$(=max([Date]))"}>}Sales)

 

purna
Contributor III
Contributor III
Author

hello vegar ,

expression given is working but :

=sum({<[Date]={">=$(=addmonth(max([Date]),-2))<=$(=max([Date]))"}>}Sales)

=sum({<[Date]={">=$(=Addmonth(max([Date]),-2))<=$(=max([Date]))"}>}Sales) --this expression is working

 

Vegar
MVP
MVP

It is a typo. It should be AddMonths().  See attached qvf where I've used your sample data.

=sum({<[Date]={">=$(=addmonths(max([Date]),-2))<=$(=max([Date]))"}>}Sales)

Vegar_0-1637326109261.png