Creating a numbered field

Options
Pestomania
Pestomania ✭✭✭✭✭

Well, I probably made this more difficult than it was needed to be, but I have been playing around with some details and am trying to create a "sort column" that would allow me to put everything in a decimal to sort on for indentation purposes (since we do not have access to the gold package).

My formula is:

=IF([# of Current Ancestors]@row = 0, [Row ID]@row, PARENT([Row ID]@row) + "." + MATCH([Row ID]@row, COLLECT([Row ID]:[Row ID], [# of Current Ancestors]:[# of Current Ancestors], >=1), 0))

Currently, it is working…somewhat. if the # of ancestors needed is 0 or 1, this formula provides the correct number:

image.png

But the # of current ancestors is greater than 1, it fails and returns the row ID of it's current row, in the above case row ID 24.

So I tried adding a second column to handle greater than 1, but it only worked for current ancestor = 2.

=IF([# of Ancestors Needed]@row > 0, INDEX(COLLECT(Test:Test, [Process Identifier]:[Process Identifier], LEFT([Parent Process]@row, FIND(" - ", [Parent Process]@row) - 1)), 1) + "." + IFERROR(MATCH([Row ID]@row, COLLECT([Row ID]:[Row ID], [# of Ancestors Needed]:[# of Ancestors Needed], >=1), 0), ""), "")

image.png

I would REALLY like to get this to match up in one column to auto-populate this data.

What is the final definition of what I am looking for:

  • When there is no ancestor (# of current ancestors = 0 and # of Ancestors Needed = 0), return the row ID for current row.
  • When there is an ancestor (# of current ancestors is greater than 0), return the value in "Test" of the ancestor + a decimal point + the next number in the sequence 1, 2, 3, etc.

Example:

  • Parent Process ROW ID: 2
  • Child Process 1: 2.1
  • Child Process 2: 2.2
    • 3rd party process 1: 2.2.1
    • Critical Application 1: 2.2.2

I hope this makes sense. I did attach some sample data below.

Answers

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!