Question

How can I add an increment at each change in an attribute value.

  • 5 February 2016
  • 3 replies
  • 47 views

Badge

I have a list of observations where the assetID may appear a number of times, so I have added an "Increment" attribute that I want to populate with 01,02,03,04 which will recurr with each change in assetid. I can do this in excel, by using the if statement looking at the row above. =IF(A2=A1,B1+1,1) how can I do this in FME?

My data looks like this - and want to add the suffix which I have added manually here as an example

Inspectionsuffix to addWW201601201784601WW201601201784602WW201601201784603WW201601201784604WW20001206523401WW20001206523402WW20001206523403WW20001206523404WW20001206523405WW20001206523406


3 replies

Badge +7

See above - you need to use a Counter, with the Counter Name set to your attribute. Then pad the string, and concatenate it, and Bob's your uncle.

Userlevel 2
Badge +17

Alternatively the StringFormatter can also be used instead of the StringPadder.

  • Attributes: _count
  • Format String: 02d
Badge

Thanks guys. Perfect, and so easy when you know how!

Reply