Solved

Assigning ascending ID to duplicate values - ignoring unique values

  • 14 August 2019
  • 3 replies
  • 19 views

Hi all,

I would like to add a field to my vector data assigning a sequential ID to duplicate values. However I would like to ignore unique values leaving them with a COUNT of 0.

This table can hopefully explain what I would like to achieve better than me attempting to write it!

VALUECOUNT103051525354607172

 

I started off with a Statistics Calculator grouping by my VALUE using the Total Count Attribute and the Cumulative output port. This counts each unique value sequentially but it also assigns a COUNT of 1 to unique values.

Is there another way of finding duplicates apart from the Duplicate Filter first? The Duplicate Filter doesn't appear to filter the truly unique values from duplicates. As in a the first VALUE of 7 and 5 would go through the unique port then the further 7 and 5 values would pass through the duplicate port.

I hope this makes sense to someone!

FME version 2019.1.0.0

icon

Best answer by ebygomm 14 August 2019, 17:14

View original

3 replies

Userlevel 2
Badge +12

First use the StatisticsCalculator (group by value, using numeric count), followed by a Tester (_count = 1) to define all unique values. Use an AttributeCreator on the Passed port of the Tester to add the attribute Count (value 0).

Then use a Counter transformer on the Failed port of the Tester (start at 1, using the Value attribute as the name of the counter).

That should give you the above result.

Badge +10

Use a matcher to find all non-unique values and send them to a counter with a count start of 1 and using the value attribute as the counter name, all unmatched values get set with a value of 0

Userlevel 2
Badge +17

If the VALUE attribute values in your data will always be sorted like they are in the example you posted above (ie. like values grouped together), then another potential method is using conditional values in the AttributeManager with Adjacent Feature Attributes enabled.

Create the COUNT attribute first and set the attribute value to 0 using an AttributeCreator. Then use an AttributeManager with Adjacent Feature Attributes enabled for 1 prior feature and 1 subsequent feature. Use the following conditional statements:

This should create the output that you want.

Reply