Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I have a straight table with the following Dimension which displays data for the previous 7 days. varViewDate simply sets the "current date" of the data to look at:
=Date(if(Date>=($(varViewDate)-7) and Date<=($(varViewDate)-1), Date),'DD/MM/YYYY')
And expressions to display the corresponding revenue and budget for each of those days. These exclude any date fields from the expression so they only ever show the last 7 days:
=ONLY({$<Year=,Quarter=,Month=,Week=,Day=,Date={'>=$(=(varViewDate)-7)<=$(=(varViewDate)-1)'}>}Revenue)
=ONLY({$<Year=,Quarter=,Month=,Week=,Day=,Date={'>=$(=(varViewDate)-7)<=$(=(varViewDate)-1)'}>}RevBudget)
This all works correctly so far.
What I now want to do is display the data for the "same day" last year. "Same day" is the same day of the week in the same week of the year last year, across the range for the previous 7 days. For example Thursday 2nd June 2016 corresponds to Thursday 28th May 2015. Shown here as column "2015".
In a text box, the formula below displays the correct date last year. Changing the number 7 correctly modifies how many days before the "current day last year" is displayed:
=Date ( MakeWeekDate ( Year($(varViewDate))-1 , week($(varViewDate)-7) , weekday($(varViewDate)-7)) , 'DD/MM/YYYY' )
This needs to be incorporated in Set Analysis. I've tried many expressions, none of which display any data, I only get the Null() "-" character:
=ONLY({$<
Year=,Quarter=,Month=,Week=,Day=,Date=
{'
>= $(=Date ( Makeweekdate (
Year($(varViewDate))-1 , Week($(varViewDate)-7) , Weekday($(varViewDate)-7)
)))
<= $(=Date ( Makeweekdate (
Year($(varViewDate))-1 , Week($(varViewDate)-1) , Weekday($(varViewDate)-1)
)))
'}
>} Revenue )
I've also created a variable called SameDayLastYear and tried using that instead of the Makedate function, but without any joy.
I'm tempted to create a field in the load script to calculate the date, but hardcoding the dates for the previous year doesn’t work either:
=ONLY({$<Year=,Quarter=,Month=,Week=,Day=,Date={'>=$(=Date(42146))<=$(=Date(42152))'}>}Revenue)
I've seen similar examples on the community site which suggests this is possible. Working through other examples such as the following, I can't see why this doesn't work.
https://community.qlik.com/docs/DOC-9162
https://community.qlik.com/message/793168#793168
https://community.qlik.com/message/13511#13511
Help greatly appreciated.
Thanks
Ian
Hello Sunny ,
I tried your solution n its worked nicely for TY week but for LY it works like this
Sales TY | Sales LY | Sales Order Purchase Date |
0 | 0 | 3/13/2019 |
0 | 0 | 3/14/2019 |
0 | 0 | 3/15/2019 |
0 | 0 | 3/16/2019 |
0 | 0 | 3/17/2019 |
0 | 0 | 3/18/2019 |
0 | 0 | 3/19/2019 |
89 | - | 3/11/2020 |
67 | - | 3/12/2020 |
78 | - | 3/13/2020 |
38 | - | 3/14/2020 |
22 | - | 3/15/2020 |
31 | - | 3/16/2020 |
34 | - | 3/17/2020 |
n if i remove below condition from LY its like this
Sales TY | Sales - LY | Date |
0 | 14 | 3/13/2019 |
0 | 11 | 3/14/2019 |
0 | 94 | 3/15/2019 |
0 | 16 | 3/16/2019 |
0 | 23 | 3/17/2019 |
0 | 11 | 3/18/2019 |
0 | 12 | 3/19/2019 |
89 | 0 | 3/11/2020 |
67 | 0 | 3/12/2020 |
78 | 0 | 3/13/2020 |
38 | 0 | 3/14/2020 |
22 | 0 | 3/15/2020 |
31 | 0 | 3/16/2020 |
34 | 0 | 3/17/2020 |
Can you help.i used this expression
sum({< Date = {">=$(=MakeWeekDate(Year(today())-1, Week(today()-7), WeekDay(today()-7)))<=$(=MakeWeekDate(Year(today())-1, Week(today()-1), WeekDay(today()-1)))"}>}[Sales])
@sunny_talwar Kindly suggest.