Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join us for a live Q&A! September 21, 10 AM ET - Onboarding Fast in Qlik Sense SaaS! REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
ilanbaruch
Specialist
Specialist

date function


how can i compare between this year to last year sales in a pivot?

5 Replies
saumyashah90
Specialist
Specialist

D1=Date(DateField,'DD-MM-YYYY')

vCurYearDate1=Date(DateField,'DD-MM-YYYY');

vPrevYearDate=Date(AddYears(DateField,-1),'DD-MM-YYYY');

You can us this two variables

in your expression such as

sum({$<Field=$(vCurYearDate1)>} Sales);

sum({$<Field=$(vPrevYearDate)>} Sales);

vikasmahajan

Hii,

Following expressions

For Curr Year

=sum($<FiscalYear={$(=max(FiscalYear))}>} Sales)

for Last Year

=sum($<FiscalYear={$(=max(FiscalYear)-1)}>} Sales)

Vikas

jvitantonio
Luminary Alumni
Luminary Alumni

You can either add the field Year as a dimension or, if you don't want to add Year as a dimension, you can do:

Dimension tab: client (example)

Expression:

1) First expressions, called "Sales TY": sum({$<Year = $(=year(today())) >} Sales)

2) Second Expressions, called "Sales LY": sum({$<Year = $(=year(today())-1) >} Sales)

This will give you the Sales for this year and last year for the dimension Client.

Make sure you have in your model a field Year.

Hope this helps.

JV

ilanbaruch
Specialist
Specialist
Author

it helped,

thank you

Not applicable

Select year as a dimension

=sum({<Date={$(vmaxyear)},FinancialYear=,FinMonthName=>}Scores)

vmaxyear=max(year(Date))

=sum({<Date={$(vmaxyear-1)},FinancialYear=,FinMonthName=>}Scores)