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

Announcements
Posting on Qlik Community is temporarily paused. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Show Chart Data Based On Yearweek Range

Hi, I have a question,

I have a qvd file that consists of some fields, one of them is YearWeek Field,

I want to load the data 4 weeks ago. Lets say today's YearWeek is 1542 (Year 2015 and Week 42), in this example i want to load data that has YearWeek between 1538 (1542-4) and 1541(1542-1).

The problem is i cant directly minus the yearweek with 4, because the year problem, let's say yearweek 1501 , the result i expect are yearweek between 1449,1450, 1451, 1452.

Is it possible to make it ?

Thanks, really appreciate your help

Labels (1)
1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

I suggest creating a new column in your script called SortField

LOAD YEARWEEK,

          AutoNumber(YEARWEEK) as SortField

FROM yourSource

Order By YEARWEEK;

and then may be this:

=Sum({<SortField = {"$(='>=' & (Max(SortField) - 3) & '<=' & (Max(SortField)))"}>} QTY)

View solution in original post

8 Replies
sunny_talwar
MVP
MVP

What is the problem with using the solution provided to you by Digvijay here: Get Week Based on FileName

sunny_talwar
MVP
MVP

I mean once you have them in a variable you can restrict a resident load with the variable you just created

LOAD blahblah

Resident Something

WHERE Match(YearWeek, $(var1), $(var2), $(var3), $(var4));

Anonymous
Not applicable
Author

Hi Sunny,

Thanks for response.

i think i must change the title.

The problem is not in load statement. But in displaying the chart in qlikview dashboard. i have load the data, let's say 1530, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541

When i choose 1541 on the list box, i want to show the data 4 months ago, so it will be 1538, 1539, 1540, 1541.

So i want to get the maximum value and minimum value to be used in my chart expression like this,

=sum({< YEARWEEK={'>=$(vYearMin) <=$(vYearMax)'}>}QTY)

do you have any idea ? because i cant find peek function in qlikview dashboard. (not in load statement)

sunny_talwar
MVP
MVP

I suggest creating a new column in your script called SortField

LOAD YEARWEEK,

          AutoNumber(YEARWEEK) as SortField

FROM yourSource

Order By YEARWEEK;

and then may be this:

=Sum({<SortField = {"$(='>=' & (Max(SortField) - 3) & '<=' & (Max(SortField)))"}>} QTY)

Anonymous
Not applicable
Author

Hi Sunny,

do you mean AutoGenerate ?

I cant find AutoNumber function here.

it only has AutoGenerate.

Thanks

sunny_talwar
MVP
MVP

Look at the below screenshot:

Capture.PNG

Anonymous
Not applicable
Author

Hi Sunny,

Okay, i already find that function.

And Yes, it solve my problem perfectly.

Thanks in advance Sunny

sunny_talwar
MVP
MVP

Awesome

I am glad we finally got it working.

Best,

Sunny