# Qlik Sense App Development

Contributor

## growth rates in Qlik Sense

Hello,

I would like to create a new variable in Qlik Sense for growth rates.   As an example of what I'm looking for:

[Alabama Jobs] is the main field that I'm pulling from an external database-- I would like to compute the period over period growth rate as in column three.   There there a way to hard code this in the data editor ?

 Date Alabama Jobs Period over period growth rate 10.2015 159 11.2015 200 26% 12.2015 130 -35% 1.2016 250 92% 2.2016 140 -44% 3.2016 110 -21% 4.2016 100 -9% 5.2016 100 0% 6.2016 100 0% 7.2016 180 80% 8.2016 340 89% 9.2016 249 -27% 10.2016 200 -20% 11.2016 242 21%
1 Solution

Accepted Solutions
Contributor

## Re: growth rates in Qlik Sense

I see.  I've attached the QVF ----the measure is already created titled State jobs_yy% change.

a. (Sum({\$<MonthYear={'Sep2016'}>}BLS_jobs_state) / Sum({\$<MonthYear={'Sep2015'}>}BLS_jobs_state))-1

Thanks.

29 Replies

## Re: growth rates in Qlik Sense

Something like this:

Temp:

Date(Date#(Date,'M.YYYY'),'M.YYYY') as Date

[Alabama Jobs]

FROM

the_source_data

;

Result:

Date,

[Alabama Jobs],

Num([Alabama Jobs] / Previous([Alabama Jobs]) - 1, '#%;-#%') as [Period over period growth rate]

RESIDENT

Temp

ORDER BY

Date

;

DROP TABLE Temp;

talk is cheap, supply exceeds demand
Contributor

## Re: growth rates in Qlik Sense

What if I wanted to set the growth rate to a year on a monthly occurring series?

## Re: growth rates in Qlik Sense

Then first aggregate the numbers at those levels. But that's something that's usually done in the charts, not the script. Doing those kind of aggregations in the charts gives more flexibility as selections will work nicely with that. Fixing the numbers in the script is less flexible. It's normally only done if necessary for performance reasons.

talk is cheap, supply exceeds demand
Contributor

## Re: growth rates in Qlik Sense

Are you referring to creating a measure on the front end?  Could you provide an example of how I would aggregate to get year over year growth rates?

Contributor

## Re: growth rates in Qlik Sense

So just to clarify what I'm trying to achieve, I'm looking t o compute the growth rate for each month over the same month a year ago.

So,   Oct2016/Oct2015 - 1

## Re: growth rates in Qlik Sense

Yeah, creating a measure. I'm going to assume you have a field called Year and you're using that as dimension in your chart or table. You can use Sum([Alabama Jobs]) to sum up those amounts so you get totals for each year. If you use a simple table then you can use the Above() function to refer to the value of the row above. So Above(Sum([Alabama Jobs])) would return the sum for the previous year. You can then create a measure that divides the two values to calculate the year-on-year variation: Sum([Alabama Jobs]) / Above(Sum([Alabama Jobs])) - 1.

If you sort the Year dimension in descending order you'd need to use the Below() function instead of Above().

talk is cheap, supply exceeds demand
Contributor

## Re: growth rates in Qlik Sense

For a multiyear series (with monthly frequency), how do we know Sum() will only sum one year?

## Re: growth rates in Qlik Sense

A measure will be aggregated over the values of your dimension (unless you overrule that). So if you use Year as a dimension you will get totals per year value.

talk is cheap, supply exceeds demand

## Re: growth rates in Qlik Sense

Ok, that's going to be more complicated. The best way to deal with this kind of problem is to add a so-called As-Of table to your data model. Before we start with that you need to view a video and read two blog posts:

A Beginners' Introduction to Set Analysis (video)

A Primer on Set Analysis

The As-Of Table will be used to create a new field that will be used as dimension in the charts and in the set analysis expression that we'll need for the solution to your question. That new field will link to the real Month field so we can select the Month values we're interested in and calculate the value for the months we want to compare, e.g. Oct2016 with Oct2015. We'll need some set analysis expressions to calculate those results.

View the video and read the blog posts and let me know if you don't understand how those things will help us create the solution to your problem.

talk is cheap, supply exceeds demand