Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
ishansjain2095
Creator
Creator

How to sum the values of GrossSaleAmount and ReturnSaleAmount for CurrentMonth and PreviousMonth ?

Hi All,

Facing some problem with the script I wanted the sale of current month (CM) and previous month (PM) like this as shown below :

sum({<[Month Year]={'Dec-19'}>}GrossSaleAmount)
+
sum({<[Month Year]={'Dec-19'}>}ReturnSaleAmount)

&

sum({<[Month Year]={'Jan-20'}>}GrossSaleAmount)
+
sum({<[Month Year]={'Jan-20'}>}ReturnSaleAmount)

But not able to make it as dynamically .

Please help.

 

Regards,

Ishan 

Labels (1)
1 Solution

Accepted Solutions
ishansjain2095
Creator
Creator
Author

Hi Kashyap,

Thanks for the expression I have successfully done the expression by creating variables of current month and previous month. 

View solution in original post

2 Replies
Kashyap_R
Partner - Specialist
Partner - Specialist

Hi

If you have a date column, try this

Previous Month:

sum({<[Date]={{">=$(=MonthStart(Addmonths(max([Date]),-1)))<=$(=MonthEnd(Addmonths(Max([Date]),-1)))"}}>}GrossSaleAmount)

+

sum({<[Date]={{">=$(=MonthStart(Addmonths(max([Date]),-1)))<=$(=MonthEnd(Addmonths(Max([Date]),-1)))"}}>}ReturnSaleAmount)

Current Month:

sum({<[Date]={{">=$(=MonthStart(Addmonths(max([Date])))<=$(=MonthEnd(Max([Date])))"}}>}GrossSaleAmount)

+

sum({<[Date]={{">=$(=MonthStart(max([Date]))<=$(=MonthEnd(Max([Date])))"}}>}ReturnSaleAmount)

Hope this Helps 

Thanks

Thanks and Regards
Kashyap.R
ishansjain2095
Creator
Creator
Author

Hi Kashyap,

Thanks for the expression I have successfully done the expression by creating variables of current month and previous month.