Select to view content in your preferred language

How can I restart a row counter in FME at the beginning of each year?

206
2
2 weeks ago
FarzanehAhmadikordasiyabi
Emerging Contributor

I have a dataset with a year attribute (e.g., 2025, 2026). I want to generate a rowid that starts at 1 for each new year and increments sequentially.

Example:

  • For 2025 → rowid should be 1, 2, 3 …

  • For 2026 → rowid should reset back to 1, 2, 3 …

I then want to concatenate the last two digits of the year with the padded rowid to create a WorkOrderID like:

  • 250001, 250002 …

  • 260001, 260002 …

Which FME transformers or workflow should I use to reset the counter per year?

0 Kudos
2 Replies
RyanUthoff
MVP Regular Contributor

If you already have a workflow for separating the years (like using a TestFilter), then you can just use the Counter transformer for each year and each Counter will start at 0 (or whatever number you like).

I'm sure there is a more elegant way of doing it, but that's the first way I thought of right off.

0 Kudos
FarzanehAhmadikordasiyabi
Emerging Contributor

Thanks @RyanUthoff . There is an easy way to do it since I'm using a counter to count rows. In the Counter transformer I should add the year field to the Count Domain parameter. 

0 Kudos