Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Calculate an average of a week

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 ?

 

Date16/02/201617/02/201618/02/201619/02/201620/02/201621/02/201622/02/201623/02/201624/02/201625/02/201626/02/201627/02/201628/02/201629/02/201601/03/2016
promo111111000011111
CA1022355838836838388387442212
261
Date16/02/201617/02/201618/02/201619/02/201620/02/201621/02/201622/02/201623/02/201624/02/201625/02/201626/02/201627/02/201628/02/201629/02/201601/03/2016
promo111111010111111
CA1022355838836838388387442212
294

Sans titre.png

4 Replies
Anonymous
Not applicable
Author

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)

Anonymous
Not applicable
Author

I need to calculate of the sum of the first 7 times in which Promo ={1}

nsm1234567
Creator II
Creator II

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

jolivares
Specialist
Specialist

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