Formula Help, Adding text

Hello I’m trying to create a formula to wear when I enter a number into a field of a table it will add text to the front of that number. For example If I enter 1 I want (A00) to be added in front. but it I add 10 I want (A0) to be added in front. is there any way I can do this?

Hi @Luke_Jamison, and welcome to this community! :handshake:

Perhaps something like this: Format("A{1:000}", [Text you enter in another cell]).

Let me know if it helps.
Cheers!

1 Like

@Federico_Stefanato Thank you, and thanks for the reply. So I want to enter and add the text in the same cell. You think that would be possible?

Hi @Luke_Jamison,
In Coda (like in many other similar tools) you can’t edit a formula cell; meaning that you either use it as an input or you get the value calculated.
Therefore, you need 2 cells anyway.

Usually this is not a big issue, though. If you can explain why it would be for you, maybe we can find some alternative.

Cheers!

@Federico_Stefanato. Yea thats one of the issues I’m running into. So I want to be able to just enter a number and the if it over 10 it will only add A0 but it is under 10 the it will add A00. I just want to speed up the process of some data entry and all I need is the one field or cell.

@Luke_Jamison, have a look at this:

I don’t see any impediment in speeding up the data entry: you just focus on one cell and the other is calculated accordingly… Am I missing something?

1 Like

@Federico_Stefanato : Format is awesome! I’m using it more and more.
In the past I’ve also used a combination of concatenate() and leftpad() which also can help in creating things like this, albeit not as elegantly as format!

1 Like

Hello Federico,

Thanks for the reply, yeah I think something like that could work thank you. Appreciate the help!

Thank you,
Luke Jamison

1 Like

@Federico_Stefanato so what If i wanted to create a field that just went like A001 and the for each new row it added +1 so the next row would be A002 and so on. But my only concern is what if a row gets deleted, will the next row add 2 or would it still just add +1 from the previous row?

Hi @Luke_Jamison,

let me better understand: you need a sequential id (with a prefix) that:

  1. keep incrementing and preserve its original value? (i.e. every new row will increment by one but if I delete some rows, existing codes don’t change
  2. keep incrementing and preserve the numeric sequence? (i.e. every new row will be incremented by one but if I delete some rows, existing codes “shift” and change to preserve the numeric sequence)

@Federico_Stefanato To answer you questions yes to both. I want each new row to just add 1 and then I a row is deleted it keeps the ones before the same and then the next new row wouldn’t add 2 it would just add 1. I have attached a screenshot to hopefully explain more.

Part of the question here is what happens to “A003” if you delete “Day 2”?

@BenLee Well day 2 would never get get deleted on purpose. So what every day it is will correspond with the reel#.

Hi @Luke_Jamison,
I confess I did not fully get it :thinking:

My questions were mutually exclusive so having both of them is quite paradoxical.
However, I have a slight feeling that you need the second one.

Therefore, the formula for you code should consider the Rank() function and might be Format("A{1:000}", thisTable.Rank(thisRow, true)).

In this case you will always have a perfect sequence 1,2,...n without any “hole” in case of deletion.
Please, let me know if this is your desired use-case.

2 Likes