5 Replies Latest reply on Feb 23, 2017 10:50 PM by Patrick Van Der Hyde

# Is there a way to create something like (PREVIOUS_VALUE(0),-2)  ?

I'm working with Joshua in this thread:

What I have determined is that he needs to be able to grab a previous value, but not just in the previous index like PREVIOUS_VALUE(0) does.  He needs to look back TWO previous values.

And I've tangled myself up in my own thinking, and just need a fresh set of eyes.

Is there a way to simulate PREVIOUS_VALUE looking back two heartbeats instead of just one?

(Note:  The workbook in question there is 9.3)

• ###### 1. Re: Is there a way to create something like (PREVIOUS_VALUE(0),-2)  ?

Joe

I saw there was a potential solution in that thread.  Are you still looking for feedback and help?

Patrick

• ###### 2. Re: Is there a way to create something like (PREVIOUS_VALUE(0),-2)  ?

As far as I'm concerned there really wasn't a solution there.

At this point I have no need for what is being asked here, but it would be interesting to know if there is a way to do a PREVIOUS_VALUE type of function that looks back x-many cells.  (And no, LOOKUP wasn't the solution.  We needed the recursive capability of PREVIOUS_VALUE.  LOOKUP doesn't do that.)

• ###### 3. Re: Is there a way to create something like (PREVIOUS_VALUE(0),-2)  ?

Hi,

I'm a little late to this (I follow @Patrick so just saw his response). I've seen this kind of recursion need about once per year on the forums where someone is trying to do some complicated simulation/modeling, it's just not possible in "vanilla" Tableau because we only get the single recursion from PREVIOUS_VALUE() that just goes back one address in the partition. What we'd really need for things like this are more loop constructs.

In these cases my suggestion to users at this point is to:

a) Bang at it until something really hacky can come out like what Joshua did in the post (which I think might be more complicated than it needs to be, but I haven't looked closely enough).

b) Use the R (or as of v10.1 Python) integrations since those have loop constructs.

Jonathan

1 of 1 people found this helpful
• ###### 4. Re: Is there a way to create something like (PREVIOUS_VALUE(0),-2)  ?

Thanks for the confirmation, Jonathan.  I never like to say, "Tableau can't do that."  Which is why I started this thread -- to confirm it in this case.

• ###### 5. Re: Is there a way to create something like (PREVIOUS_VALUE(0),-2)  ?

Thank you Jonathan..  It's good to know you are always  looking over my shoulder.  Keeps me honest.