Skip to main content
Hello, 

 

 

I have a .dbf that has ID, YEAR, CODE

 

 

ID starts at 1 and every ID has 9 YEARS with an associated CODE for that given year (always 1990 to 1998 inclusive) . Therefore the same ID is 9 features long with some sort of CODE associated with it (one of 5 choices).

 

 

What i want to do is start counting at 1 when a CODE becomes different, grouped by ID. So the first year  per ID is always going to be 1 while the 2nd year could be 2 (if the same CODE) or stay at 1 if the CODE is new.

 

 

Sadly, if you use the 'hidden' GroupBy function in Counter transformer and set it to attribute ID you will get a count that is not 1 anymore when that CODE occurs again. I've tried using Multiple Feature Support in Attribute Creator but again this is not working.

 

 

My basic need is this, with the new COUnt attribute;

 

 

ID---YEAR---CODE---COUNT

 

1----1990-----A-----------1

 

1----1991-----B-----------1

 

1----1992-----B-----------2

 

1----1993-----B-----------3

 

1----1994-----E-----------1

 

1----1995-----E-----------2

 

1----1996-----A-----------1

 

1----1997-----A-----------2

 

1----1998-----A-----------3

 

 

Thanks in advance
Hi, I think "Multiple Feature Attribute Support" option works fine.

 

 

Takashi
Thanks Takashi but given my example above, imagine now that ID 2 comes straight underneath (9 entries again) and that the 1st CODE for ID 2 is also A, wouldn't that get a COUNT of 4 under that system? Is there anyway of incorporating IF Id is different in Feature(-1) then reset to 1 regardless?
No. I've missed such a situation. Correct the test condition.

 

 


Hi Takashi, thanks for your update but it doesn't seem to work....

 

 

I'm getting the following: AttributeCreator: Unable to find closing bracket for function Evaluate in

 

 

From your blog post 'Getting Started with Tcl in FME' I can see that perhaps there needs to be some square brackets? also I can't figure out quite where i'd even put closuing brackets for @Evaluate as it looks pretty good to me  (??)

 

 

thanks
The Test Conditions dialog should look like this. You can enter the expression for "Output Value" using the Arithmetic Editor. Tcl is not necessary in this case.

 

 

 

Then, Parameter Condition will be:

 

 


Lovely thanks, I had not entered Output Value correctly into the Arithemtic Editor, thanks again
Hi,

 

 

If u add a periodic calculator (in your case 9) to it you get:

 

creator:

 

 

 

another creator

 

 

 

 

 

and its conditions

 

 

 

.
..it will negate the need to use an ID to differentiate the 9 year periods.

 

(wich is not very elegant, rows of same value to an attribute..;) Superfluant attribute as the same info is kept in the periodvalue).

 

 

You can make the value 9 a parameter, so can have different periods.
The ID represents a spatially unique area with 9 records fot the given area over 9 years. This is tied to other datasets by the same area specific ID, so i'm afraid it must stay 🙂

Reply