6 Replies Latest reply on Nov 5, 2018 6:24 AM by Ryan Schultz

# Creating An Index

I Am attempting to create a sort of index.  I would like to create a field called "Batch" .  I would like the value of that field to start at 1 and increase by 1 every time the Tank_1_Recipe_Stage changes from 0 to !. So, for the included data, I would have a total of 18 Batches.  I have tried using the Lookup, Previous_value, and Index functions, but cant seem to get it dialed in.  Any help would be much appreciated.

• ###### 1. Re: Creating An Index

So, for the included data, I would have a total of 18 Batches.

Could you explain this a little bit more. Now you have 13 unique values in Tank 1 recipe. What would be your expected output ?

• ###### 2. Re: Creating An Index

The recipe stages are components of a batch.  So depending on what is being injected, each batch would be comprised of some combination of recipe stages.  What I want is that each time the . Tank_1_ recipe_stage changes from 0 to 1, this would indicate a new batch.  So,  All records between 2:00:03 and  2:29:19 would be Batch 1.  All records between 2:30:02 and 3:14:06 would be Batch 2.  All records between 3:15:02 and 4:19:24 would be Batch 3, and so on.  I hope I am explaining this properly.  Thank you again for taking the time to look at this

• ###### 3. Re: Creating An Index

Also, I miscounted on my original post.  There should be a total of 17 batches .

• ###### 4. Re: Creating An Index

I apologize for the multiple replies.  I am still learning how to use this forum.  I am attaching a revised workbook without all the unnecessary fields.  Please let me know what else I can provide .

• ###### 5. Re: Creating An Index

Create a calculated field:

IF ATTR([Tank_1_Recipe_Stage])=1 AND LOOKUP(ATTR([Tank_1_Recipe_Stage]),-1)=0

THEN  PREVIOUS_VALUE(0)+1

ELSE

PREVIOUS_VALUE(0)

END

• ###### 6. Re: Creating An Index

Ombir,

That worked.  Thank you so much.  I was close but just couldn't get the pieces together.  Again, your help is very much appreciated.