Skip to main content
Solved

How to get more than one Counter transformer with same name?


benedito

I have 3 counters in my workspace. And I want them to produce a single count. The documentation says : "When multiple Counters have the same name and Count Scope is Global, they produce a single count."

 

In my workspace the Scope of the Counter is set to Global but, I cannot figure it out how to write the same name for the three counters!

When trying to write the same name for the counter transformers, FME (2021.1) automatically changes the names to Counter_2, Counter_3, Counter_X .... so I'm not getting a unique count for my workspace, what I have is three different counts starting from 0.

 

This is a basic question, Is the name of the transformer what I have to change to get a unique count? I'm sure I'm missing something and maybe someone can help me with this.

 

Thanks!

Best answer by tomfriedl

I think you need 2 counter like this.

  • Counter_2 count normaly
  • Counter_3 + Counter_4 start with _count.max + 1

The result is unsort: Counter_4 = 3, 5, 7 Counter_3 = 4, 6, 8

Test Count2

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

12 replies

tomfriedl
Contributor
Forum|alt.badge.img+13
  • Contributor
  • May 17, 2022

You found the "Name" of the counter here:

Counter Parameters > Advanced > Count Domain


benedito
  • Author
  • May 17, 2022
tomfriedl wrote:

You found the "Name" of the counter here:

Counter Parameters > Advanced > Count Domain

Thanks for your response!

My Count Domain for the three counters is the same default "counter"Count Domain


tomfriedl
Contributor
Forum|alt.badge.img+13
  • Contributor
  • May 17, 2022

In 2021.2 and 2022.0 the counter works in my Test, Result is 0, 1, 2:

Test Count


benedito
  • Author
  • May 17, 2022
tomfriedl wrote:

In 2021.2 and 2022.0 the counter works in my Test, Result is 0, 1, 2:

Test Count

Ok, I have done the same test, my Result is 1,0,0... 😕

imagen


ctredinnick
Supporter
Forum|alt.badge.img+18
  • Supporter
  • May 17, 2022

I was able to reproduce your result.

Basically, the counters are counting correctly, but they only count within each run of the workspace.

So in your screenshot, the cache on Counter_2 is from an earlier run of the workspace than the caches on Counter_4 and Counter_5. Renaming two of the counters and only partially running the workspace causes only those two counters to be used.

You have the right parameters. Either rerun the entire workspace, or turn off feature caching.


benedito
  • Author
  • May 17, 2022
ctredinnick wrote:

I was able to reproduce your result.

Basically, the counters are counting correctly, but they only count within each run of the workspace.

So in your screenshot, the cache on Counter_2 is from an earlier run of the workspace than the caches on Counter_4 and Counter_5. Renaming two of the counters and only partially running the workspace causes only those two counters to be used.

You have the right parameters. Either rerun the entire workspace, or turn off feature caching.

Thanks for responding!

I tried it but didn't work for me :( ... but your answer led me to think that maybe the counters are restarting the count after a FeatureWriter??, as my workspace actually is something like this:

imagen


tomfriedl
Contributor
Forum|alt.badge.img+13
  • Contributor
  • May 17, 2022

Counter_2 and Counter_3 override Counter. I don't understand your intention to do this.


benedito
  • Author
  • May 17, 2022
tomfriedl wrote:

Counter_2 and Counter_3 override Counter. I don't understand your intention to do this.

Yeah, this is a simplification of the actual workflow, but what I wanted to get is like a serial number for each one.

For instance, having 10 features I want to numer them like this:

 

imagenimagen


tomfriedl
Contributor
Forum|alt.badge.img+13
  • Contributor
  • Best Answer
  • May 17, 2022

I think you need 2 counter like this.

  • Counter_2 count normaly
  • Counter_3 + Counter_4 start with _count.max + 1

The result is unsort: Counter_4 = 3, 5, 7 Counter_3 = 4, 6, 8

Test Count2


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • May 17, 2022
benedito wrote:

Thanks for responding!

I tried it but didn't work for me :( ... but your answer led me to think that maybe the counters are restarting the count after a FeatureWriter??, as my workspace actually is something like this:

imagen

I think this is potentially an issue with version 3 of the Counter? If i use version 2 of the Counters it works as expected, if then upgrade the counters in the workflow to version 3, in 2021.2 I do not get the expected result. One for safe i think?


benedito
  • Author
  • May 17, 2022
tomfriedl wrote:

I think you need 2 counter like this.

  • Counter_2 count normaly
  • Counter_3 + Counter_4 start with _count.max + 1

The result is unsort: Counter_4 = 3, 5, 7 Counter_3 = 4, 6, 8

Test Count2

I've tried this and is working! For now the order is not important so I'll use this alternative, but I'm still not fully understanding the way Counters are working together on the same workspace. 😅

Thanks!


maisels
Contributor
Forum|alt.badge.img+3
  • Contributor
  • September 16, 2022

In Version 4 of the counter transfomer ( FME Version 2022.1) this error still exists.

Maybe safe can fix this please.

Thanks.


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