Skip to main content
Solved

Count Increased Based on a Condition Being Met


tiztrain
Contributor
Forum|alt.badge.img+3

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

tiztrain wrote:

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.

 

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

5 replies

nielsgerrits
VIP
Forum|alt.badge.img+54

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+3
  • Author
  • Contributor
  • January 15, 2024
nielsgerrits wrote:

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+54
  • Best Answer
  • January 15, 2024
tiztrain wrote:

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+3
  • Author
  • Contributor
  • January 16, 2024
tiztrain wrote:

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+54
tiztrain wrote:

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 :)


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