Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Save $600 on Qlik Connect registration! Sign up by Dec. 6 to get an extra $100 off with code CYBERSAVE: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
akuligod
Contributor
Contributor

Sum within a given date range

trying to sum up sales data (with field YYYYMM) between two date ranges.  For ex: Sum of sales data between campaign date (201801) and campaign after date (201803) essentially trying to sum all sales data for the period of  3 months (before/after campaign)

Something on the lines of the formula below : any help is much appreciated.

NUM(Sum({<DataType={'Sales'},

YYYYMM={"=YYYYMM<CampaignDateAfter_YYYYMM"},

YYYYMM={"=YYYYMM>CampaignDate_YYYYMM"},

>}Sales_Cost_USD))

3 Replies
Anil_Babu_Samineni

Hiw about this?

NUM(Sum({<DataType={'Sales'},

YYYYMM={"=YYYYMM<CampaignDateAfter_YYYYMM and YYYYMM>CampaignDate_YYYYMM"},

>}Sales_Cost_USD))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
vupen
Partner - Creator
Partner - Creator

If you would like to filter the YYYYMM field based on the values in the Campaign Date field for upto 3 months, you can use something like this:

Sum({<DataType={'Sales'}, YYYYMM = {">=$(=addmonths(CampaignDate_YYYYMM, 0))<=$(=addmonths(CampaignDate_YYYYMM,3))"}>} Sales_Cost_USD)

If the fields YYYYMM and/or CampaignDate_YYYYMM are not valid Date fields, you may add such fields to the data model.

akuligod
Contributor
Contributor
Author

Thank you Sir, looks like this will work.