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).

  • 10 December 2021
  • 6 replies
  • 0 views

Badge +8

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

Badge +4

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.

 

Userlevel 5
Badge +29

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?

Badge +8

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.

Userlevel 5
Badge +29

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

Badge +8

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?

Userlevel 5
Badge +29

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

Reply