Hi,
Â
Â
Two AttributeCreators do that without exploding features.
Â
In the first one, create an attribute (e.g. named "count"), and set 0.
Â
In the second one, set 10 conditional value settings to count changes between every adjacent two attributes.
Â
count = If CODE01 != CODE00 Then count + 1 Else <No Action>
Â
count = If CODE02 != CODE01 Then count + 1 Else <No Action>
Â
...
Â
count = If CODE10 != CODE09 Then count + 1 Else <No Action>
Â
Â
Since the AttributeCreator evaluates every expression in the order from top to bottom, finally the "count" attribute will store the number of changes.Â
Â
Â
But it may be too tedious. Python or Tcl scripting could be better solution.
Â
-----
Â
# Script Example for PythonCaller
Â
def countChange(feature):
Â
  count = 0
Â
  v0 = feature.getAttribute('CODE00')
Â
  for i in range(1,11):
Â
    v1 = feature.getAttribute('CODE%02d' % i)
Â
    if v1 != v0:
Â
      count += 1
Â
    v0 = v1
Â
  feature.setAttribute('_count', count)
Â
-----
Â
# Script Example for TclCaller
Â
proc countChange {} {
Â
  set count 0
Â
  set v0 tFME_GetAttribute "CODE00"]
Â
  for {set i 1} {$i < 11} {incr i} {
Â
    set v1 ÂFME_GetAttribute "CODE}format %02d $i]"]
Â
    if  {$v1 != $v0} {incr count}
Â
    set v0 $v1
Â
  }
Â
  return $count
Â
}
Â
-----
Â
Â
Takashi
Or, by using transformers:
Â
Â
Â
Â
Using the listpopulator and a customloop..
Â
Â
thanks both.
Â
Â
Takashi: I have set up the Creators but in the 2nd one with conditionals, I am getting no further than 1 in the 'count' attribute (it does remain 0 where no change at all occurs - correctly), it seems to not bother with the remaining rules should one be satisfied;
Â
Â
Looks like you are using FME 2014.
Â
Such a waterfall-like continuous calculation in the AttributeCreator can be performed in FME 2015, but it may not work in FME 2014 unfortunately.
Â
Â
Well, here is another thought.
Â
Use the NullAttributeMapper to replace every Missing attribute with 0.
Â
Then, this long expression in the ExpressionEvaludator or the AttributeCreator returns the required number.
Â
-----
Â
(@Value(CODE00)!=@Value(CODE01)?1:0)
Â
+(@Value(CODE01)!=@Value(CODE02)?1:0)
Â
+(@Value(CODE02)!=@Value(CODE03)?1:0)
Â
+(@Value(CODE03)!=@Value(CODE04)?1:0)
Â
+(@Value(CODE04)!=@Value(CODE05)?1:0)
Â
+(@Value(CODE05)!=@Value(CODE06)?1:0)
Â
+(@Value(CODE06)!=@Value(CODE07)?1:0)
Â
+(@Value(CODE07)!=@Value(CODE08)?1:0)
Â
+(@Value(CODE08)!=@Value(CODE09)?1:0)
Â
+(@Value(CODE09)!=@Value(CODE10)?1:0)
Â
-----
Â
Â
After that, replace 0 attribute with Missing with the second NullAttributeMapper, if necessagy.
In this case, the ^ operator (bit wise exclusive OR) can also be used instead of the != operator. FYI.
Â
-----
Â
(@Value(CODE00)^@Value(CODE01)?1:0)
Â
+(@Value(CODE01)^@Value(CODE02)?1:0)
Â
...
Â
+(@Value(CODE09)^@Value(CODE10)?1:0)
Â
-----
Thanks Takashi, i upgraded to FME 2015 and your original answer worked  :)
Hi,
Â
Â
Here is one without loop, still based on lispopulator. (and replacing of Empty/null/missing attributes due to inefficiency of listpopulator)
Â
Â
Â
Â
more efficient and elegant.
Â
Â
If you would prevent Null/Missing/EMPTY attributes then no NullAttributeMapper would be nescessary and there would be no need for any "manual labor"
Â
Â
Â