AppSheet Formula that looks at previous values and creates a new value

I am trying to make an AppSheet formula that does the following:

  • Looks at the last CR number, e.g. CR1141

  • Writes a new CR number e.g. CR1142

Notes:

  • This should work based on the largest number in the previous CR’s regardless of whether it was the last CR used.

  • Some CR numbers may be like this “CR1141c”, in which case it needs to ignore whatever comes after the numbers and suggest “CR1142”

Is the number always between 1000 and 9999? Is the prefix always with two letters?

1 Like

Prefix always has 2 letters, yes. Preferably would like to keep going beyond 9999.

Would really appreciate if anyone has a solution

There might be cleaner solution but this should work between 00000 and 99999.

“CR”&RIGHT(“0000”&(NUMBER(MID([Code],3,IF(NUMBER(MID([Code],3,5))>0,5,4)))+1),5)

1 Like

This formula may be useful

“CR”&right(concatenate(“000000”;(1+Count(reportexample[CR_id])));6)

or if we ignore a predefined mask:

“CR”&(1+Count(reportexample[CR_id]))