The number of rows in my table varies every time as I don't know how many rows of my raw data. I want to define a new column with a specified sequence of numbers repeat in it. such as repeat 123 in the new column:
1
2
3
1
2
3
.
.
.
Can I do this? Thanks.
Solved! Go to Solution.
@LeiCheng
If I understand your requirement correctly, we can use generate Row tools to do something like this.
@Qiu You are amazing, thank you!
@LeiCheng
Glad to be any help.
There is an underutilized Mod function that can assist with this as well.
Where you have sequential RecordID and you need Groups that repeat in sequence like this:
| Record ID | Group |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 1 |
| 5 | 2 |
| 6 | 3 |
Drop this syntax in a formula tool:
Replace(
ToString(
IF [RecordID] <=3
THEN [RecordID]
ELSE Mod([RecordID], 3)
endif
),
'0','3')
The Mod function provides the remainder after dividing by a given number (in this case 3). Numbers that are divisible by 3 will return 0, so we need to wrap this in a replace function to replace the 0 with 3.
You'll probably want to immediately follow this with a select tool to convert Group back to INT

