# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Talk to Experts, a LIVE Q&A Webinar. Bring your Qlik Sense Business questions on Aug. 4th. Register
cancel
Showing results for
Did you mean:
Highlighted
Partner

## Yet another this period vs last year comparison question

Hi all,

Consider this data model (I have attached the Qlik Sense file as well):

 date station product volume 2020-04-03 100 1 300 2020-04-02 100 1 200 2020-04-01 100 1 100 2019-04-03 100 1 70 2019-04-02 100 1 80 2019-04-01 100 1 90

I wish to create this straight table:

However,  I cannot seem to figure out how to calculate the Last Year data. I expect the data for 2019 to be shown. So for 2020-04-03 I would have the volume for 2019-04-03 in last year column: 70.

I am going to have the last year value displayed in different charts, where the date dimension is not added, where I expect this task to be easier, but since date is a dimension in this table, I am struggling to find a solution.

I have tried

``Sum({1<date={"=\$(=AddYears(date, -1))"}>}volume)``

Also fiddle around with TOTAL and p(), but not entirely understanding how to solve this.

Appreciate any pointers 🙂

Thanks

Labels (2)

• ### Set Analysis

1 Solution

Accepted Solutions
Highlighted
Specialist II

## Re: Yet another this period vs last year comparison question

You need to manage it at a data level; see attached

5 Replies
Highlighted
Specialist II

## Re: Yet another this period vs last year comparison question

You need to manage it at a data level; see attached

Highlighted
Partner

## Re: Yet another this period vs last year comparison question

But is this really not possible with set expressions?

Highlighted
Partner

## Re: Yet another this period vs last year comparison question

For others who might be interested, this is the suggested load script:

``````Data:
date, station, product, volume
2020-04-01, 100, 1, 100
2020-04-02, 100, 1, 200
2020-04-03, 100, 1, 300
2020-02-29, 100, 1, 400
2019-04-01, 100, 1, 90
2019-04-02, 100, 1, 80
2019-04-03, 100, 1, 70
2019-02-28, 100, 1, 10
2019-03-01, 100, 1, 20
];

left join (Data) load date(AddYears(date,1),'YYYY-MM-DD') as date , volume as volume1Y Resident Data;``````

Highlighted
Specialist II

## Re: Yet another this period vs last year comparison question

Not in a table; what you need to consider is that, when in a table, the qlik engine has no visibility of the dimension value. In your case, in the first row (date 2020-03-04) you don't have access to the value of the date (2020-03-04) to be able to subtract 1 year and get the resulting volume from 1 year earlier.  You've tried this expression: