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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Suri6999
Contributor
Contributor

loading always latest 4 weeks data in script level

HI ALl,

 

I am having one field called  "week" which contains the week data like below.

Week

2022/01

2022/02

.....

2022/12

Now i want to load last weeks data from week field into Qlik through script.

Can you help me ASAP?

 

 

Labels (1)
3 Replies
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi @Suri6999 

You want a WHERE statement. Is that week number plain text in the source?

If so you will need to construct the week in that format:

WHERE Week = WeekYear(today()-7) & '/' & num(Week(today()-7), '00')

Hope that helps.

Steve

Suri6999
Contributor
Contributor
Author

seems like it will give the data for latest week

But i want data for last 4 weeks..

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Sorry @Suri6999 

I was looking at the description, rather than the subject of the post.

You just need to build this out with OR statements:

WHERE Week = WeekYear(today()-7) & '/' & num(Week(today()-7), '00')
OR Week = WeekYear(today()-14) & '/' & num(Week(today()-14), '00')
OR Week = WeekYear(today()-21) & '/' & num(Week(today()-21), '00')
OR Week = WeekYear(today()-28) & '/' & num(Week(today()-28), '00')

If you also have a date field in the source data, rather than just a Week value then you could do it much more elegantly with that, e.g.

WHERE Date >= WeekStart(today()-28) AND Date <= WeekEnd(today()-7)

That is making an assumption about your data which might not be correct though.

Hope that helps.

Steve