Question

Get the highest value record

  • 23 October 2018
  • 3 replies
  • 57 views

Badge +5

I have set of records as below,

LinkIDoccurenceNAME123455ZXC2123457ABC1567893XYZ1567892SDF2567895YTR3

I need the record with maximum count based on occurence attribute. For example, from the above table, I need to extract only the below records.

Output,

LinkIDoccurenceNAME123457ABC1567895YTR3

Could anyone give me some suggestions please.


3 replies

Userlevel 1
Badge +21

Sorting by occurence in descending order, followed by a duplicate filter with a key attribute of LinkID will give you only max values out of the unique port.

Userlevel 4
Badge +26

Use a StatisticsCalculator to get the max value per LinkID

 

Settings you need to set are:

 

group by = LinkID,

 

Attributes to analyze = occurrence

 

Calculate Attributes = only use '_max'.

 

If you know that the LinkID is ordered you can 'Input Ordered' to Yes for improved performance. If you'Re unsure then just leave is as no to be safe

 

 

The 'Complete' output port will then have added the _max value for each group of LinkID.

 

 

You can then use a Tester to see if 'occurrence = _max' .

 

This method is good if you want also get any cases where the max occurrence value can be equal.
Userlevel 2
Badge +16

Another options:

Sorter (sorting by occurrence (numeric, descending).

Sampler (group by LinkID, first 1 feature).

This will get you the required result and might be the faster way if you have a large dataset..

Reply