# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

New Contributor

## KPI comparison current year vs previous year

I have a small problem and I was wandering if anyone could help me. I've looked other threads, but couldn't solve it.

For selected year total sales KPI I created this expression:

Sum({\$<OrderDate.autoCalendar={Year}>}Sales)

Now I'm having trouble doing it for the previous year total sales KPI that I want to put next to the first one.

How do I do it?

1 Solution

Accepted Solutions
Contributor

## Re: KPI comparison current year vs previous year

Previous year:

Sum({<[OrderDate.autoCalendar.Year] = {"\$(=Max(Year(OrderDate)) - 1)"}>} Sales)

Current year:

Sum({<[OrderDate.autoCalendar.Year] = {"\$(=Max(Year(OrderDate)))"}>} Sales)

It will be based on your selection to get what is the lastest(max) possible year, and minor 1 to get its previous year.

I agree with Jerry Jackson on solution: Sum({\$<OrderDate.autoCalendar.YearsAgo={1}>}Sales)

Why dont it work?

@

6 Replies
Contributor III

## Re: KPI comparison current year vs previous year

Try:

Sum({\$<OrderDate.autoCalendar.YearsAgo={1}>}Sales)

New Contributor

## Re: KPI comparison current year vs previous year

Thanks Jerry for the answer, but it doesn't work.

Contributor III

## Re: KPI comparison current year vs previous year

Prior Year:

Sum({<Year=,OrderDate={">=\$(=YearStart(MakeDate(Max(Year)),-1))<=\$(=YearEnd(MakeDate(Max(Year)),-1))"}>}Sales)

Current Year:

Sum({<Year=,OrderDate={">=\$(=YearStart(MakeDate(Max(Year))))<=\$(=YearEnd(MakeDate(Max(Year))))"}>}Sales)

New Contributor

## Re: KPI comparison current year vs previous year

Thanks again Jerry, but still nothing.

Contributor

## Re: KPI comparison current year vs previous year

Previous year:

Sum({<[OrderDate.autoCalendar.Year] = {"\$(=Max(Year(OrderDate)) - 1)"}>} Sales)

Current year:

Sum({<[OrderDate.autoCalendar.Year] = {"\$(=Max(Year(OrderDate)))"}>} Sales)

It will be based on your selection to get what is the lastest(max) possible year, and minor 1 to get its previous year.

I agree with Jerry Jackson on solution: Sum({\$<OrderDate.autoCalendar.YearsAgo={1}>}Sales)

Why dont it work?

@

New Contributor

## Re: KPI comparison current year vs previous year

Thanks Phi, your solution worked, no idea why Jerry's didnt

Thanks a lot to both of you.

Cheers