Skip to main content
Solved

How can I count the number of times a specified value from an attribute appears within a given feature/row?


enriquep

I would like to see if a value from a specified column/attribute can be counted into another column based on how many times it appears across multiple columns. I hope to do this for every feature/row of a dataset.

 

Example of the data below :

See values in "Dominant Value" field that is present across multiple fields. 

In this case, I would like specify the value in the DominantValue field, and I would like to see how many times this value appears in fields: AreaCount1, AreaCount2, AreaCount3, AreaCount4, Areacount5, and AreaCount6. The number of times it appears would be stored in a field called dvcounter. For example the desired output would look something like the below table:

DesiredOutput 

Does anyone have any recommendations as to what transformers or workflows can provide this "count" field? I've attached a portion of the csv data that I am working with and the workspace that I am working on.

 

This workflow builds on top of question that was recently answered by @Takashi Iijima​ :

https://community.safe.com/s/feed/0D54Q00009RcXusSAF

 

 

Best answer by kailinatsafe

Hello @enriquep​ , I think we can use lists and list transformers to accomplish this. I've created a workspace with the data you provided. I tried my best to annotate the process so it is clear. This workspace was created with FME 2022.0.

 

CountOccuranceSS 

Please take a look and let me know if you have any questions / issues accessing the workspace. I'm sure there is a also a method for accomplishing this with Python. Best, Kailin

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

2 replies

kailinatsafe
Safer
Forum|alt.badge.img+21
  • Safer
  • Best Answer
  • April 20, 2022

Hello @enriquep​ , I think we can use lists and list transformers to accomplish this. I've created a workspace with the data you provided. I tried my best to annotate the process so it is clear. This workspace was created with FME 2022.0.

 

CountOccuranceSS 

Please take a look and let me know if you have any questions / issues accessing the workspace. I'm sure there is a also a method for accomplishing this with Python. Best, Kailin


enriquep
  • Author
  • May 11, 2022
kailinatsafe wrote:

Hello @enriquep​ , I think we can use lists and list transformers to accomplish this. I've created a workspace with the data you provided. I tried my best to annotate the process so it is clear. This workspace was created with FME 2022.0.

 

CountOccuranceSS 

Please take a look and let me know if you have any questions / issues accessing the workspace. I'm sure there is a also a method for accomplishing this with Python. Best, Kailin

Hi @kailinatsafe​ , thank you! This was very helpful.


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