Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

dave-firmograph
New Contributor

Calculating Difference Current v. Prior Year

We need to calculate and use in a line graph the difference, based on ID, of the prior year v. current year.


So far, we have 2 years but this will need to work generally.  Naturally the first year 2015 would have no "difference" record.  The subsequent years would.


  

IDYearRatio
100163820163.57
100163820154.18
100334620150.25
100334620162.19
100375020150.49
100375020160.50
100376420153.07
100376420164.07
100376720162.11
100376720152.26

We are calculating the ratio, currently, as a measure.


Is this all best done in the load script, or as a calculated measure?

2 Replies

Re: Calculating Difference Current v. Prior Year

Let's consider one row

ID Year Ratio
1001638 2016 3.57

Can you explain 3.57??

nitin_01
Contributor

Re: Calculating Difference Current v. Prior Year

Hi David,

        As per my understanding, from your query.

Create two variable :- vMax=Max(Year)  & vPrev=$(vMax)-1

Put vMax into you first expression and vPrev in second expression with your needed measure, that would give you two lines in chart where you can see the difference in current & Previous year.

Current Vs Prev.PNG

Regards,

Nitin G.