Skip to main content
Solved

Count the Number of Responses


calvin.fme
Contributor
Forum|alt.badge.img+2

Hi All,

I have a survey asking participants to rank their favourite colours—Red, Blue, and Green—in numerical order (1, 2, 3).

I want to use the results to create a workflow that counts how many times each colour has been picked based on the ranking.

Here is some example data.

Sample Data
Unique_ID Colour Rank
1 Red 3
1 Blue 2
1 Green 1
2 Red 1
2 Blue 2
2 Green 3
3 Red 1
3 Blue 2
3 Green 3

 

What I am trying to achieve
Colour  Rank_ 1_Count Rank_2_Count Rank _3_Count
Red 2 0 1
Blue 0 3 0
Green 1 0 2

Best answer by geomancer

I went another way, using ListKeyValuePairExtractor transformer from FME Hub.

 

View original
Did this help you find an answer to your question?

6 replies

j.botterill
Influencer
Forum|alt.badge.img+34
  • Influencer
  • March 11, 2025

Have you tried using the AttributePivoter?

The AttributePivoter receives features with attributes, restructures and regroups them based on specified Group By attributes, and calculates summary statistics based on a designated Attribute To Analyze in order to form a Pivot table output.


calvin.fme
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • March 11, 2025

Thanks for getting back. Unfortunately it’s not giving me the table structure I wanted. 

 


I am chasing something like this



 

 


j.botterill
Influencer
Forum|alt.badge.img+34
  • Influencer
  • March 11, 2025

Did some further research. 

Dmitri suggestion seems useful but I can’t see his attachment 

Looking at this one, they place an AttributeExposer after the AttributePivoter > Data port

 something like this 

 


calvin.fme
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • March 11, 2025

Thanks for getting back again. I am not getting any luck with the outputs after entering 1,2,3. Are you able to provide your workbench file?

 

Also, is there any chance to further proceed the data structure by having the colours grouped like the following

 

Much appreciated!!!


pallegama
Contributor
Forum|alt.badge.img+8
  • Contributor
  • March 11, 2025

Hi ​@calvin.fme ,

The column calculation as per your initial message can be achieved with the AttributePivoter as suggested by ​@j.botterill. I think what you experienced is a bug in AttributePivoter you can see in some versions like FME 2023. In those affected versions, AttributePivoter adds .0 suffix to attribute names when they have integers. Therefore, those attribute names created by AttributePivoter looks like 1.0, 2.0, 3.0 instead of 1,2,3. This can easily be rectified with a BulkAttributeRenamer.

The attached workspace produce the the output as you mentioned in the last response. The workflow got little bit complex to handle Grand Total column and row.

Hope this helps!


geomancer
Evangelist
Forum|alt.badge.img+46
  • Evangelist
  • Best Answer
  • March 11, 2025

I went another way, using ListKeyValuePairExtractor transformer from FME Hub.

 


Reply


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