2 Replies Latest reply on Feb 23, 2019 12:42 AM by KALPIT GOYAL

# How to calculate KPI based on year before?

Hi.

I have a situation where I need to calculate the KPI based on year before. If the sales of the current year is bigger then the previous year, then the sales is increasing and vice versa. I know that Tableau already have the quick table calculation (difference from)  that already solve my problem, but the requirement want the difference being stated in shape (arrows up and down). Below the screenshot for my analysis.

I've tried using my own calculation to differentiate the indicator based on difference between years but it's still doesn't work. Refer the image below, you can see that Machines have negative value for the difference in sales from the previous year, but still the shape indicate as 'Up'.

This is my calculation for the indicator:

IF ZN(SUM([Sales])) - LOOKUP(ZN(SUM([Sales])), -1)<0

THEN "down"

ELSE

"up"

END

I've also attached my workbook in here. Thank you in advanced.

• ###### 1. Re: How to calculate KPI based on year before?

Hi Shahirah,

This calculation works fine for me. Make sure you use the discrete values on shapes and color.

Results were computed along Table across

if ZN(SUM([Sales])) - LOOKUP(ZN(SUM([Sales])), -1) >0 then "Up"

else

"down"

end

Thanks

Akram

1 of 1 people found this helpful
• ###### 2. Re: How to calculate KPI based on year before?

Hi Shahirah,

Your Calculation is totally fine ,the only change in your worksheet required is to do Indicators(Colors and Shapes) in marks card as Compute using Table(across).