Increment unique form of ID automatically

tvinci
New Member

Hi AppSheet Community,

I have a list of IDs that look like this that I want to increment automatically:

So technically it is a “text” type. Is casting allowed in AppSheet so I can split the numbers by hyphen and increment the numbers every time I reach past the letter C?

Thanks

Solved Solved
0 5 605
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

Untested:

concatenate(
  (
    number(index(split(any(sort(My Table[ID], true)), "-"), 1))
    + switch(
      index(split(any(sort(My Table[ID], true)), "-"), 2),
      "4c", 1,
      0
    )
  ),
  "-",
  switch(
    index(split(any(sort(My Table[ID], true)), "-"), 2),
    "1a", "1b",
    "1b", "1c",
    "1c", "2a",
    "2a", "2b",
    "2b", "2c",
    "2c", "3a",
    "3a", "3b",
    "3b", "3c",
    "3c", "4a",
    "4a", "4b",
    "4b", "4c",
    "4c", "1a",
    ""
  )
)

View solution in original post

5 REPLIES 5

Steve
Platinum 4
Platinum 4

Why???

These IDs correspond to positions within an object used to conduct a biological test on horses.

Steve
Platinum 4
Platinum 4

Untested:

concatenate(
  (
    number(index(split(any(sort(My Table[ID], true)), "-"), 1))
    + switch(
      index(split(any(sort(My Table[ID], true)), "-"), 2),
      "4c", 1,
      0
    )
  ),
  "-",
  switch(
    index(split(any(sort(My Table[ID], true)), "-"), 2),
    "1a", "1b",
    "1b", "1c",
    "1c", "2a",
    "2a", "2b",
    "2b", "2c",
    "2c", "3a",
    "3a", "3b",
    "3b", "3c",
    "3c", "4a",
    "4a", "4b",
    "4b", "4c",
    "4c", "1a",
    ""
  )
)

Wow @Steve, a million thanks to you Helpful as always!

Not really. It’ll fail with the transition from single- to double-digits, then from double- to triple-, and so on. Really need the number before the dash separate.

Top Labels in this Space