Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Amir_mohamed
Contributor
Contributor

current week minus 30 set analysis

Hi All, 

I hope you could help me with this.

I am trying to build a Straight table that shows the weeks by columns 

and i'm struggling with one thing, ex; current week is 25 and I want to build a set analysis that calculates current week minus 30 which will technically date be Nov last year, 

How can I get that in the calculations, if I do current week (25) minus 30 , the week number will be -5 not week 47 from last year

Amir_mohamed_0-1624546040374.png

 

Labels (6)
3 Replies
brunobertels
Master
Master

hi

may be like this 

 

if(week(today())<30,

week(today())-30+52,week(today())-30)

so for week 25 = 25-30 = -5 +52 = 47 

Amir_mohamed
Contributor
Contributor
Author

Hi ,

Thank you for your reply. Isn't there a way to create a new column in the data that will  show a sequence number as the table i'm thinking to create will be a rolling 10 months but by week 

ex;

Load week_year ,

     autonumber 

;

so it'll be 

week_year column      autonumber column

week 47-2020                 1

48-2020                             2

 

etc; so when i'm building the set analysis in the table i'll just do sum({<week_year ={'1'}>}sales), then on the second column of staight table, sum({<week_year ={'1+1'}>}sales), third column, sum({<week_year ={'1+2'}>}sales) etc

brunobertels
Master
Master

may be this 

autonumber(week_year, class(week_year,30)) as autonumberID 

 

Where in class function 30 is the count of week you want to  class