Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
BARC’s The BI Survey 19 makes it official. BI users love Qlik. GET REPORT
Partner
Partner

Line chart with last 52 weeks, Compare with last year

Hi guys,

I have attached a test app, which shows volume distribution for the last two years (Chart 1).

I am attempting in Chart 2 and 3 to show volume distribution for the last 52 weeks with two lines: this year and last year.

This year = last 52 weeks

Last year = The same 52 weeks, the year before.

Measures:

This year

Avg({$<Date={">=$(=Date(Today()-365, 'DD/MM/YYYY'))"}>}Volume)

Last year

???

So, the last data point in the chart is current week vs same week last year, and the entire charts contains a total of 52 data points (one for each week)

How do I do that?

Best Regards,

Rasmus

Screen Shot 2018-09-19 at 14.53.27.pngScreen Shot 2018-09-19 at 14.54.29.png

Tags (1)
1 Solution

Accepted Solutions
mikaelsc
Contributor III

Re: Line chart with last 52 weeks, Compare with last year

use week(yourDateField) as Dimension.

otherwise you're showing 2 Measures that will only give results for the correcponding year

View solution in original post

2 Replies
mikaelsc
Contributor III

Re: Line chart with last 52 weeks, Compare with last year

use week(yourDateField) as Dimension.

otherwise you're showing 2 Measures that will only give results for the correcponding year

View solution in original post

Highlighted
Partner
Partner

Re: Line chart with last 52 weeks, Compare with last year

Thanks for your help.

I actually already tried this, but wanted the current week to be the last point of the chart. If we only use week(date) then week 52 will always be the last point on the chart.

But I managed to fix it with this addition to my calendar:

Dual(Replace(WeekName($1), '/', '-'), Mod(52-(Week(Today()) - Week($1) + 1), 52)) AS [WeekL52] Tagged ('$axis', '$weekl52')

So, this will shift the weeks, so that current week becomes "week 52" and thereby the last point on the chart.