Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
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

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
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)