Skip to main content
Solved

Count Increased Based on a Condition Being Met

  • January 15, 2024
  • 5 replies
  • 117 views

tiztrain
Contributor
Forum|alt.badge.img+6

Hi,

I am wanting to create a count that increases if a condition has been met. So as an example, if TIME is greater than 100 then the COUNT increases, otherwise it stays the same:

 

TIME - COUNT

20 - 1

70 - 1

130 - 2

220 - 3

40 - 3

80 - 3

370 - 4

 

Been stuck trying to figure this out for a while. With Python this would be easier with the use of variables but I am struggling with FME on this one.

 

I see the Count transformer has 'Group By' capability but I don't think that helps me for this situation.

Best answer by nielsgerrits

So I had already done this with the Attribute Manager but the part I am struggling with is the conditional statement.

 

I was using the Count() function to count whenever the condition is met and that works fine for when the count increases but is there a way to display the count without adding another count. If that makes sense?

 

image

How I do this:

  • AttributeCreator to create attribute _count with no value.
  • Second AttributeCreator with one prior feature.
    • If previous value has no value, then _count = 1
    • Else if value > 100, _count = previous _count + 1
    • Else _count = previous _count

Not sure if this is the official way, but it works.

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

nielsgerrits
VIP
Forum|alt.badge.img+62

If you want to do this in the excel way, look at previous rows etc, you can do this using the AttributeCreator, Advanced: Attribute Value Handling, Enable Adjacent Feature Attributes. Then use conditional values.


tiztrain
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • January 15, 2024

If you want to do this in the excel way, look at previous rows etc, you can do this using the AttributeCreator, Advanced: Attribute Value Handling, Enable Adjacent Feature Attributes. Then use conditional values.

So I had already done this with the Attribute Manager but the part I am struggling with is the conditional statement.

 

I was using the Count() function to count whenever the condition is met and that works fine for when the count increases but is there a way to display the count without adding another count. If that makes sense?

 

image


nielsgerrits
VIP
Forum|alt.badge.img+62
  • Best Answer
  • January 15, 2024

So I had already done this with the Attribute Manager but the part I am struggling with is the conditional statement.

 

I was using the Count() function to count whenever the condition is met and that works fine for when the count increases but is there a way to display the count without adding another count. If that makes sense?

 

image

How I do this:

  • AttributeCreator to create attribute _count with no value.
  • Second AttributeCreator with one prior feature.
    • If previous value has no value, then _count = 1
    • Else if value > 100, _count = previous _count + 1
    • Else _count = previous _count

Not sure if this is the official way, but it works.

 


tiztrain
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • January 16, 2024

So I had already done this with the Attribute Manager but the part I am struggling with is the conditional statement.

 

I was using the Count() function to count whenever the condition is met and that works fine for when the count increases but is there a way to display the count without adding another count. If that makes sense?

 

image

Oh this is interesting. I was stuck on how to use the existing attribute in my Conditional Visibility but did not realise that you just need to create the value in a AttributeCreator and then reuse it in the second one. Man makes calculating this so much easier. Works perfectly.

Appreciate it.


nielsgerrits
VIP
Forum|alt.badge.img+62

So I had already done this with the Attribute Manager but the part I am struggling with is the conditional statement.

 

I was using the Count() function to count whenever the condition is met and that works fine for when the count increases but is there a way to display the count without adding another count. If that makes sense?

 

image

Cheers :)