Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

need only last 4 four weeks data

Hi Experts,

I am new to qlikview.

Here is my requirement

I nee to display last 4 weeks data from max(date) only and it should roll up week wise. Here date I am getting as time stamp.

I know how to get week wise data. But problem is to get last 4 weeks data only.

Can somebody help me on this issue.

Regards,

Nanada

3 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Create a table with the week as the dimension, and the following expression:

     =Sum({<datefield = {">=$(Date(Max(datefield) - 28)) <=$(=Date(Max(datefield)))"}>} metricfield)

Replace datefield and metricfield with the correct fieldnames.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Anonymous
Not applicable
Author

you can do it either in calculated dimension or in Expression using set Analysis

calculated Dimension:

if (week(yourdatefield)>=week(max(yourdatefield))-4 and week(max(yourdatefield), week(yourdatefield)

expression

sum({<yourdatefield={'>=$(=weekstart(week(max(yourdatefield))-4)<=$(=weekend(week(max(yourdatefield))'}>}

Be Aware that weeks before week 4 will not goback to previous year week (eg 52)

if you have a weekfield the expressions can be easier

jonathandienst
Partner - Champion III
Partner - Champion III

You can let Qlikview take care of some of that, so if a calculated dimension is preferred:

     Dimension: If(datefield >= Max(datefield) - 28 And datefield <= Max(datefield), week(datefield))

     Expression: Sum(metricfield)

(But I think the set analysis on the metric in my first post will be faster if you are dealing with a large data set)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein