Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to divide between previous year

Hi there,

I have a table with states / year / month dimensions, I need to calculate the following formula:

T = Value_Month_Year / Value_Month_PreviousYear

Example:

My first table looks like:

 

201420142014201520152015
JanFebMarJanFebMar
State110203091520
State2153040151520
State3204050102030

And I need a second table to show:

T = Value_Month_Year / Value_Month_PreviousYear

 

201520152015
JanFebMar
State10.90.750.66666667
State210.50.5
State30.50.50.6

For All the Years since 2010

How can I achieve this???

Thanks in advance

Berenice

2 Replies
ramoncova06
Specialist III
Specialist III

what is the current expression that you are using ?

how does your date field looks ?

you could probably do something like this

sum(value)

/

sum({<month = {">=$(=(addyears(month,-1)))"}>}value)

Not applicable
Author

Thanks,

I'm using this expression:

=

Avg(ActividadInd)

/

Avg({<Año = {$(=Year(AddYears(MakeDate(Año,Mes),-1)) )}, Año = >} ActividadInd)

But in my table obviously the value is divided by itself because I'm ignoring the year selected

I've attached the qv file

table.PNG