Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ishanbansal1204
Contributor III
Contributor III

Calculating previous week value

Hi All,

I have a weekend date as my filter option. As we follow different calendar so we have a different weekend dates.

Weekend date is the filter option.

I am calculating week on week where current week value is sum(sales)

the previous week formula that i have written is

SUM({<WEEKEND_DATE = {'$(=MAX(WEEKEND_DATE-7))'}>} sales)

but after many try and attempts of doing this i am getting the value as 0 always. Please suggest.

Note : Weekend date is difference of 7 days

18 Replies
pathiqvd
Creator III
Creator III

Hi,

  Then create variable like this

vTT=date(date(date#(max(DT1),'DD-MMM-YY'),'DD/MM/YYYY')-7,'DD/MM/YYYY')

ishanbansal1204
Contributor III
Contributor III
Author

Sorry tried but did not work..

parimikittu
Creator II
Creator II

Hi Ishan,

SUM({<WEEKEND_DATE = {'$(=MAX(WEEKEND_DATE-7))'}>} sales). Will work if an already weekend is selected in the App. So please use below expression


SUM({<WEEKEND_DATE = {'$(=MAX({1}WEEKEND_DATE-7))'}>} sales). It will by default take the max weekend_date and retrive the value -7.

ishanbansal1204
Contributor III
Contributor III
Author

Hi Vj,

The problem is when - 7 days is included in the query its not working but if i remove that -7 it is giving the current week information correctly but last week is not.

parimikittu
Creator II
Creator II

SUM({<WEEKEND_DATE = {'$(=MAX({1}WEEKEND_DATE)-7)'}>} sales). Sorry have corrected the code. Replaced MAX({1}WEEKEND_DATE-7) with MAX({1}WEEKEND_DATE)-7.

vinieme12
Champion III
Champion III

try

SUM({<WEEKEND_DATE = {"$(=DATE(MAX(WEEKEND_DATE)-7,'YourDateFormatforWeekendDate')"}>} sales)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
ishanbansal1204
Contributor III
Contributor III
Author

Hi All,

No Luck.

I tried with most of the date formats but its not working.. if i am fetching the value for filtered weekend date its displaying correctly but by the time i add " - 7 " to it.. the value becomes zero.

ishanbansal1204
Contributor III
Contributor III
Author

Hi,

I managed to get the query right, but another problem came up

SUM({<WEEKEND_DATE = {'$(=MAX(WEEKEND_DATE))'}>} sales)

- SUM({<WEEKEND_DATE = {'$(=MAX(DATE(DATE(WEEKEND_DATE - 7,'DD/MM/YYYY'),'DD-MM-YYYY')))'}>} sales)

I am subtracting the selected weekend sales - previous weekend sales

but rather than that it displaying me the values in 2 separate lines.

Can you please suggest

HirisH_V7
Master
Master

Hi,

Pls provide some sample data and mention which query your'e using in script.

Did u try this,from my above post.

  1. Sum({$<WEEKEND_DATE={"$(=Weekend(Max(WEEKEND_DATE),-1))"}>}sales) 

-Hirish

HirisH
“Aspire to Inspire before we Expire!”