Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
March 26 at 10am ET: See how Qlik drives growth and value in ISV segment - REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
MZqlik
Contributor III
Contributor III

Sum Previous week in a table (without using Below function)

Hi All.
I have a column called week_starting which identifies the beginning of a week from an order_date.
Using the following I can find the previous week from the field week_starting. =WeekStart(week_starting,-1).
I have also put the above into a variable vPrevWeek.

I am trying to get the sum of the previous week by looking at the current week in a table (I don't want to use the function above/below in this case because I want to do something different later.
I want to be able to show in the kpi's as well the previous weeks depending on what is selected.
The below formula is not working. Do you have any suggestions on how to achieve this?
I cannot get the dates function working in an aggregation.  

=Count({$< week_starting = { '$(vTestPrevWeek)' }>} order_code)

Screenshot 2024-11-22 223557.gif

Labels (5)
3 Replies
Qrishna
Master
Master

Havent tried on any data but this would replace an expression with above/below. this expression uses max(). Both Should work

=Count({$< week_starting = { "$(Max({<week_starting = {"<$(=week_starting )"}>} week_starting))"}>} order_code)
 
=Count({$< week_starting = { "$(Max({<week_starting = {"<$(=Only(week_starting ))"}>} week_starting))"}>} order_code)

 

if they error out, put some sample data, will try reproduce your scenario.

 

MZqlik
Contributor III
Contributor III
Author

Both don't work. I guess there is not a way then as I have tried everything. 

Kushal_Chawda

@MZqlik  It will not work without above function as you have added week itself as dimension. Try below for previous week

=sum(aggr(above(Count(order_code)),(week_starting,(NUMERIC))))