Here you go. Tableau does not have a looping function, but it does have PREVIOUS_VALUE(), which is a table calculation that returns the previous value of itself. So, what I did was create the following two calculations:
Index Store - this stores an index value for the current row:
IF FIRST()==0 THEN
ELSEIF ATTR([Action]) = "B" THEN
Last Changed Index - this one looks up the prior value of the Index Store to get the correct result:
IF ATTR([Action]) = "B" THEN
Note that I had to add an ID column to your data, by default Tableau aggregates dimensions so we needed something to uniquely order the Action column.
Is this what you were looking for?
last changed index.twbx.zip 9.3 KB
Hi Jonathan, thanks a lot for the help. I had my logic ready, but was not sure how to use in Tableau. The previous_value is what we can use. This has solved my issue. Thanks again .