Qlik Community

Qlik Sense App Development

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

joeybird
Contributor II

Year / minus year qlik sense

Hi

have the expression

as one line on a chart

count(distinct{< CalendarYear = {"$(=max(CalendarYear))"}>} [Custid])    'Current Year'

and this on a second line on a chart

count(distinct{< CalendarYear = {"$(=max(CalendarYear)-1)"}>} Custid) 'Previous year'

When i pick from a filter pane CalendarYear  e.g 2015

current year line appears, but previous year turns to 0, when there is 10 years worth of data

how can i please amend the set analysis to avoid this

kind regards

1 Solution

Accepted Solutions
Not applicable

Re: Year / minus year qlik sense

I am going to guess that the "Calendar Year" you use in the filter, is the same one you use in the Set Analysis.

That means when you select 2015 in the filter, it limits your data set to only be CalendarYear = 2015. Your Set Analysis will therefore not return anything for 2014, 2013.

You could create a standalone filter list, in the load script, from CalendarYear, calling it something that ensures it will not automatically link to a field e.g. "MyFilterYear"

Then use that dimension as your filter, changing your Set Analysis to use MAX(MyFilterYear)

8 Replies
MVP
MVP

Re: Year / minus year qlik sense

Are you making the selection just the the CalendarYear field or are there other calendar related fields where you are making selections?

joeybird
Contributor II

Re: Year / minus year qlik sense

Hi

just the CalendarYear field as a filter pane

please help

MVP
MVP

Re: Year / minus year qlik sense

Would you be able to share screenshots of with and without selection?

joeybird
Contributor II

Re: Year / minus year qlik sense

Hi

no really but

Date is main field of order data

this links to a calendar table, where it links to date, and then to a column called CalendarYear, and column  CalendarMonth ect.

the same happens on a pivot chart too.

please help

MVP
MVP

Re: Year / minus year qlik sense

I don't see anything wrong with the expression you have posted. Unless you can share a sample or screenshot, not sure if I can provide any advice.

joeybird
Contributor II

Re: Year / minus year qlik sense

Hi

i basically have a pivot table (Same for line chart ) that as Months on left hand side... and three columns on the right

Current year, Year -1, and Year-2

i want if someone picks from the filter pane a calendar year 2015

current year becomes 2015, Year -1 shows 2014, and year -2 shows 2013

Please help

Not applicable

Re: Year / minus year qlik sense

I am going to guess that the "Calendar Year" you use in the filter, is the same one you use in the Set Analysis.

That means when you select 2015 in the filter, it limits your data set to only be CalendarYear = 2015. Your Set Analysis will therefore not return anything for 2014, 2013.

You could create a standalone filter list, in the load script, from CalendarYear, calling it something that ensures it will not automatically link to a field e.g. "MyFilterYear"

Then use that dimension as your filter, changing your Set Analysis to use MAX(MyFilterYear)

joeybird
Contributor II

Re: Year / minus year qlik sense

Hi

thank you team