Skip to main content

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Skip the ticket, Chat with Qlik Support instead for instant assistance.
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

Sum of Values based on date field

Hello all, 

For the below table, I intend to use an KPI measure to show MTD Sales. But the MTD Sales should show the summary of values until last week. For getting the last week data, I use the expression

=sum({<Date={num(WeekStart(Today()-7))}>}[Total-FG.MTD Sales Units]).

But I know the above expression ain't right to get the correct value. I'm completely new to Qlik sense and have started learning.

Could you please help me with an expression to get the sum of MTD Sales for last week for the KPI measure

P.S. The Week numbers are linked to Sunday's date, that's why I have used week start function and also the Week numbers in my calendar and Qlik's are different as the only common calendar field is Date. Also on the above expression I tried to wrap the Date as number, because only then it is working due to the formats. 

Thank you


Product GroupWeek NumberYearMonthDateMTD Sales Units
A BoxW01 20202020Jan 20202019-12-2941
A BoxW02 20202020Jan 20202020-01-05146
A BoxW03 20202020Jan 20202020-01-12284
A BoxW04 20202020Jan 20202020-01-19410
A BoxW05 20202020Jan 20202020-01-26629
A BoxW06 20202020Feb 20202020-02-02169
A BoxW07 20202020Feb 20202020-02-09289
A BoxW08 20202020Feb 20202020-02-16533
A BoxW09 20202020Mar 20202020-02-23189


3 Replies
Partner - Creator III
Partner - Creator III

Hello @Arvind_07 ,

Maybe something like this

=sum({$<Date={"<=$(=date(WeekStart(max(Date)-7)))"}>}[Total-FG.MTD Sales Units])


=sum({$<Date={"<=$(=date(WeekStart(Today()-7)))"}>}[Total-FG.MTD Sales Units])

Regards Eddie

Contributor III
Contributor III

Thanks Eddie @eddie_wagt . For some reason it is still showing all the Dates values instead of last week's. Is there any way to sort this out

Partner - Creator III
Partner - Creator III

I read your requirements again, but do you need the sum of values for the past 7 days or do you need the sum of values of the previous week? Example: This week is week number 15 (202115) and previous week is (202114) . And I guess you want only show the sum of values of week 14