Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
How to do a rollback for the first 7 times/days in which Promo ={1} ?
I use the following expression to calculate an average rolling back 7days
((Sum({<Promo ={1},DateTest={">=$(=Date(Today() - 9)) <$(=Date(Today()-2))"}>} [Prix de vente TTC]))/7)
My problem if the first 7 days I have Promo <> {1} and Promo ={1} for example , the resultas will be false , I need to do a rollback fo the first 7 days in wich promo = 1 ? How to modify the expression ?
Date | 16/02/2016 | 17/02/2016 | 18/02/2016 | 19/02/2016 | 20/02/2016 | 21/02/2016 | 22/02/2016 | 23/02/2016 | 24/02/2016 | 25/02/2016 | 26/02/2016 | 27/02/2016 | 28/02/2016 | 29/02/2016 | 01/03/2016 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
promo | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | |
CA | 10 | 2 | 2 | 35 | 58 | 38 | 836 | 8 | 38 | 38 | 83 | 87 | 44 | 22 | 12 | |
261 | ||||||||||||||||
Date | 16/02/2016 | 17/02/2016 | 18/02/2016 | 19/02/2016 | 20/02/2016 | 21/02/2016 | 22/02/2016 | 23/02/2016 | 24/02/2016 | 25/02/2016 | 26/02/2016 | 27/02/2016 | 28/02/2016 | 29/02/2016 | 01/03/2016 | |
promo | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | |
CA | 10 | 2 | 2 | 35 | 58 | 38 | 836 | 8 | 38 | 38 | 83 | 87 | 44 | 22 | 12 | |
294 | ||||||||||||||||
week(weekstart(Date)) as week
than we can write the code as follows
((Sum({<Promo ={1},DateTest={">=$(=Date(Today() - 9)) <$(=Date(Today()-2))"},week=>} [Prix de vente TTC]))/7)
I need to calculate of the sum of the first 7 times in which Promo ={1}
Hi There,
Would it be practical to do something like the attached? The idea is to have a sort of threshold date and then use set analysis to simply check where the promo code is 1 and the date is also larger than the threshold date. This gives seven entries and skips the zero entries.
Regards
As I see you have a date for each promo code, right?
Date(Max({<Promo={1}>} Date,7))
This give you the 7 date you have, for example:
Date, Promo
1/1/2016, 1
2/1/2016, 1
3/1/2016, 1
4/1/2016, 0
5/1/2016, 0
6/1/2016, 1
7/1/2016, 1
Date(Max({<Promo={1}>} Date,4)) =2/1/2016