Javier Lafuente
Javier Lafuente

Reputation: 1

How can I calculate a percentage change from the previous month in tableau?

I have created a table that has two columns: the first one containing the name of several campaigns and the second one containing their investment. In addition, this table has a month filter, so that the campaign investments for only one month appear.

To this table I want to add a third column in which the percentage variation with respect to the previous month appears.

I have tried to do it with the following code, but as the table does not show the previous month, the field is blank.

(ZN(SUM([Investment])) - LOOKUP(ZN(SUM([Investment])), -1)) / ABS(LOOKUP(ZN(SUM([Inversión])), -1))

How can I calculate it?

Another option that has occurred to me is to create a calculated field in which the investment of the previous month appears directly and from there to make the percentage variation, but I have not been able to do it either.

Thank you very much!

Upvotes: 0

Views: 728

Answers (1)

AIViz
AIViz

Reputation: 102

Steps

  1. Create a copy of the field of you want to calculate % different from. You can do this by pressing down command button on mac and dragging the field to the side.enter image description here

  2. Click on the second field you have added. Click on quick table calculation and percent differenceenter image description here

  3. Click on edit table calculationenter image description here

  4. Select relative to previous enter image description here

Hope this helps!

Upvotes: 1

Related Questions