Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Specialist II
Specialist II

Current Year Vs Previous Year

Hello Everyone

Pls help me in CY Vs PY logic.

want to show CY Vs PY Sales.

9 Replies
Highlighted
MVP
MVP

Re: Current Year Vs Previous Year

Consider you have below script..

================

Sales:

Load * Inline

[

  Customer, Sales, Year

  A, 100, 2012

  A, 120, 2013

  B, 90, 2012

  B, 110, 2013

  C, 150, 2012

  C, 110, 2013

];

===========================

You can show CY vs LY/PY sales growth as below

Create a Straight Table

Dimension

Customer

Expressions

2012 Sales

SUM({<Year = {2012}>}Sales)

2013 Sales

SUM({<Year = {2013}>}Sales)

Growth

SUM({<Year = {2013}>}Sales)/SUM({<Year = {2012}>}Sales)-1

Don't forget to change Number formatting of Growth to percentage from Properties = Number Tab

Highlighted
Not applicable

Re: Current Year Vs Previous Year

Instead of hardcoding 2012,2013.. values, create a variable vMaxYr = Max(Year()).

for PY you can use vMaxYr-1


Highlighted

Re: Current Year Vs Previous Year

You can create variable or by the use of the SET analysis you can create the expressions for Current Yr vs Previous Yr sales. But all ready explain by the member is right.

Current Year Sales

=Sum({<Year = {'$(=Max(Year))'}>} Sales)

Or


By Formula use

=Sum({<Year = {"$(vCurrYr)"}>} Sales)

Previous Year Sales

=Sum({<Year = {'$(=Max(Year)-1)'}>} Sales)

Or

By Formula Use

=Sum({<Year = {"$(vPrevYr)"}>} Sales)

Highlighted
Creator II
Creator II

Re: Current Year Vs Previous Year

if i am using above expression i am using same values for both current year and previous year

Highlighted

Re: Current Year Vs Previous Year

You have to by pass the other fields as well and did you create the correct variables because it is demo code.

Highlighted
Creator II
Creator II

Re: Current Year Vs Previous Year

Hi

i want to compare sales for current and previous year but i am getting same values for all. pease help

so for that i have declared

current year

curr_year = Max(sold_Year)

previous year

prev_year=max(sold_year)-1

for  expression for current year

=num(sum({<sold_year = {"$(curr_year)"}>}[inv value])/(Sales_INR_Unit),'#,##0.0')

for expression for previous_year

=num(sum({< sold_Year = {"$(=$(prev_year))"}>}

[inv value]/Sales_INR_Unit),'#,##0.0')

for total growth

=num(

sum({<sold_year = {"$(curr_year)"}>}[inv value])

-

sum({< sold_Year = {"$(=$(prev_year))"}>}

[inv value])

/

sum({< sold_Year = {"$(=$(prev_year))"}>}

Highlighted

Re: Current Year Vs Previous Year

Did you check because i am getting different values

Please check the snap shot

Image.PNG

Highlighted
Creator II
Creator II

Re: Current Year Vs Previous Year

Sir

please help

i have to replace year with my column name ie sold_year

so now expression will be

sum({sold_year={'$(max(sold_year))'}>} inv_value)

correct?

Highlighted

Re: Current Year Vs Previous Year

Check on this thread please for your answers.

Re: variable declaration of last year and current year?