Skip to main content
Question

I have a set of records which have a a couple of attributes, among them one attribute identifying to which group they belong to (a,b or c).


katt
Supporter
Forum|alt.badge.img+12
  • Supporter

I want to make sure that I have the same number of records in each group. What transformer to use?

btw I want to preserve each record's attributes values as I want to write the records to a db later on.

6 replies

drc43
Contributor
Forum|alt.badge.img+11
  • Contributor
  • December 10, 2021

Hi @katt​ ,

 

It sounds like you need the StatisticsCalculator. If you set the Group By, to the group attribute in your dataset, and select the Total Count statistic, it will output both a Summary with a count of the number of records belonging to each group, and also output all the records with the count added as an attribute. Because you are only calculating a total count of records, you can use any Attribute, but I usually use the primary key when I do it. Hope that helps.

 


hkingsbury
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • December 12, 2021
drc43 wrote:

Hi @katt​ ,

 

It sounds like you need the StatisticsCalculator.  If you set the Group By, to the group attribute in your dataset, and select the Total Count statistic, it will output both a Summary with a count of the number of records belonging to each group, and also output all the records with the count added as an attribute.  Because you are only calculating a total count of records, you can use any Attribute, but I usually use the primary key when I do it.  Hope that helps.

 

I question i'd have, is do you require one feature with all counts? eg

a    b    c
21   21   21

or a feature for each count eg

grp  cnt
a    21
b    21
c    21

or are you wanting the count as a separate attribute against each feature?


katt
Supporter
Forum|alt.badge.img+12
  • Author
  • Supporter
  • December 13, 2021
hkingsbury wrote:

I question i'd have, is do you require one feature with all counts? eg

a    b    c
21   21   21

or a feature for each count eg

grp  cnt
a    21
b    21
c    21

or are you wanting the count as a separate attribute against each feature?

Yes, for example: group a =3 records; group b =17 and group c=34 records. Once I calculated the number of records per group, I want to compare them with each other. Are as many in group a as in group b and as in group c ? I want to detect if there are not the same number of records in each group. I don't mind the way it's done.


hkingsbury
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • December 13, 2021
hkingsbury wrote:

I question i'd have, is do you require one feature with all counts? eg

a    b    c
21   21   21

or a feature for each count eg

grp  cnt
a    21
b    21
c    21

or are you wanting the count as a separate attribute against each feature?

Have a look at the attached - this way is really only suitable if you're comparing a handful of groups as it requires manual attribute exposing


katt
Supporter
Forum|alt.badge.img+12
  • Author
  • Supporter
  • December 13, 2021
hkingsbury wrote:

I question i'd have, is do you require one feature with all counts? eg

a    b    c
21   21   21

or a feature for each count eg

grp  cnt
a    21
b    21
c    21

or are you wanting the count as a separate attribute against each feature?

Thank you. Would you be able to provide me a FME 2018 compatible script?


hkingsbury
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • December 14, 2021
hkingsbury wrote:

I question i'd have, is do you require one feature with all counts? eg

a    b    c
21   21   21

or a feature for each count eg

grp  cnt
a    21
b    21
c    21

or are you wanting the count as a separate attribute against each feature?

see attached, the earliest version i have is 2018.1


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings