Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create new variable using same columns

I have my data set like this

  

VendorQuarterCurrent quarter
MarketQ3 2013100
MarketQ2 2013200
MarketQ1 2013300
MarketQ4 2013100
MarketQ3 2013200
MarketQ2 2013300
MarketQ1 2013100
MarketQ4 2013200

I want new variable "Growth" so that  , growth of Q4 will be calculated from Current quater. and like wise for other quaters as well..

for ex. growth= q4/q3-1

3 Replies
sundarakumar
Specialist II
Specialist II

If you want this calculation to happen at back end then you have to add a group by to the table to group data at quarter level and sort it in ascending order then use previous function to calculate it as a Field.

If you want the same in variable you will have to do group by and capture the details to a varialbe with peek function.

But the simplest way should be to do it in the front end like sum({<Quarter={'current_quarter'}>}sales)/sum({<Quarter={'previous_quarter'}>}sales). -1

can you explain why you want it in a variable?

-Sundar

Not applicable
Author

I need a separate variable ...doing it for the ease of use to see the growth rate.

I didn't get your 1st two lines....can you show what are you trying to say?

I am new to this.

sundarakumar
Specialist II
Specialist II

PFA the sample. It shows the exaple where the requirement is handled in script.

But it is better to be calcualted in the front end like (in a text box)

=(sum({<Quarter={'2015 Q4'}>}sales)/sum({<Quarter={'2015 Q3'}>}sales))-1

-Sundar