5 Replies Latest reply on Nov 1, 2018 12:25 PM by Aashis Khanal

Difference between current-previous values

Hi,

I want to calculate the difference between current and previous values, and I am using

``` LOOKUP
```

with

``` ZN
```

For the first difference, I am receiving null.I though that ZN will give me 0.

But, I want to just leave the first value as it is and begin calculating the difference from the second value.

How can I do that?

Thanks!

• 1. Re: Difference between current-previous values

Hi George,

Let me know if the attached is what you are looking for.  If it is, and you need me to explain anything, please post back!

Regards,

Gerardo

1 of 1 people found this helpful
• 2. Re: Difference between current-previous values

Hi Gerardo,

Thanks for the solution!It was exactly was I was looking for.

I just removed the Names field and I observer that for the second difference it shows two values.And I can't understand how it comes.

It is on the sheet 2, I am attaching.

Thanks again!

• 3. Re: Difference between current-previous values

That's correct your data has two values that are the same.

Regards,

Gerardo

• 4. Re: Difference between current-previous values

Yes, you are right..But, this should not be a problem since each row of data should be used.It doesn't matter that I have some same values.I am just calculating the difference between current and previous.

But, I can see in tableau, that if you place the Value in the row shelf, it doesn't show duplicates.

Thanks!

• 5. Re: Difference between current-previous values

Hi George,

Thank you very much. It helped my resolved my similar issue.

I need to calculate difference in % between current and previous record.

> (ZN(SUM([% Free]))) - LOOKUP(ZN(SUM([% Free])), -1)

ZN() did the trick to display NULL record in case there is no previous record.