How to create a custom row number

Hi there !
I’m trying to create a custom row number for example a row number of fixed length with a prefix of a character or string.
For example…

ABC0001
ABC0002
ABC0003

I’m trying to create a formula based on the row number for example…
pad(field(“ROWID”),4,0,‘left’) but keep getting an error: no implicit conversion of Fixnum into String

UPDATE…I think i’ve done it by doing the following…

concat(“ABC”, pad(field(“ROWID”),4,“0”,“left”))
where
ROWID = this.to_s

Can anyone help ?.
Cheers
Nick

I believe you could use this forumla-

[*(‘A’…‘Z’)].sample(3).join+pad(field(“RowId”),4,“0”,“left”)

Result:
LYJ7922
RIW4232
JCX5897
CCC9687
IQM0352

Here is my schema-

{
“id”: 98168,
“num_rows”: 1000,
“file_format”: “csv”,
“name”: “forum”,
“include_header”: true,
“columns”: [
{
“name”: “RowId”,
“null_percentage”: 0,
“type”: “Row Number”,
“formula”: “”
},
{
“name”: “id”,
“null_percentage”: 0,
“type”: “Formula”,
“value”: “[*(‘A’…‘Z’)].sample(3).join+pad(field(“RowId”),4,“0”,“left”)”,
“formula”: “”
}
]
}

That’s great to know Rich !.. thanks for the tip !.
Nick

1 Like