# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Contributor III

## Sales comparison vs last year

Hello,

I have the data sample and expected result like this:

I used:

If(Flag_This_Year = 1, Date) for the dimension,

Sum({<Date ={"\$(=AddYears(Max(Date),-1))"}>}Sales) for measure sale last year, but got wrong result.

I know that it can be done with join function in data load script, I am looking for a solution on dashboard.

Any help would be greatly appreciated.

1 Solution

Accepted Solutions
Contributor II

## Re: Sales comparison vs last year

Hi,

Thanks,

RT

14 Replies
New Contributor III

## Re: Sales comparison vs last year

hi Quy You are restricting the Dimesnion field i.e If(Flag_This_Year = 1, %Date) lasy year will show "0" sales

Contributor III

## Re: Sales comparison vs last year

Hi Vishal,

New Contributor III

## Re: Sales comparison vs last year

Could you tell me the Expected  Result So i can change the expression!

Contributor III

## Re: Sales comparison vs last year

Expected result is the picture in the original post

Contributor III

## Re: Sales comparison vs last year

Hi,

try below logic

Table1:

Noconcatenate:

Current_year_Data:

sales as this_year_sales

Resident Table1

where flag_this_year=1;

join

sales as prev_year_sales

Resident Table1

where flag_this_year=0;

In front end

take straight able

dimension

year_date

Expression:

1: sum(this_year_sales)

2: sum(prev_year_sales)

Regards,

Contributor III

## Re: Sales comparison vs last year

Thanks for your reply, i am looking for a solution in front end without changing script. Is it possible?

Contributor II

## Re: Sales comparison vs last year

Hi ipcducquy,

Please see if the attached helps you.

Thanks

RT

Honored Contributor II

## Re: Sales comparison vs last year

I guess you can't.

Contributor III

## Re: Sales comparison vs last year

Thanks Rajesh, but i want to view data by date, not by month. I got 60 dates in 2 months of 2017 and 60 dates in the same months of 2018.