Solved

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

  • 10 April 2022
  • 2 replies
  • 36 views

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

 

 

icon

Best answer by kailinatsafe 20 April 2022, 14:48

View original

2 replies

Userlevel 3
Badge +13

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

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.

Reply