Qlik Community

Ask a Question

App Development

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

Join us for a live Q&A! September 21, 10 AM ET - Onboarding Fast in Qlik Sense SaaS! REGISTER
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 =if(getselectedcount(Date)=0,num(WeekStart(today()-7)),Date). But I want to use this expression to get the MTD Sales on the KPI measure for last week.

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

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


2 Replies

You could try an expression like this:

Sum({< WeekNumber, Year, Month,[Date]={">=$(=MonthStart(today(),-1))<$(=weekstart(today()))"}>}[MTD Sales Units])

Plees ekskuse my Swenglish and or Norweglish spelling misstakes
Contributor III
Contributor III

is it possible to get the above expression with Weekstart(today()-7) function alone? because my calendar month start and end dates are different than normal calendar