Skip to main content
I am new to FME and I am sorry if this question seam so basic but How can I use "CASE" statement like in SQL or "IFS /IFS" statements to do a validation logic on FME?

Hi @teburg​ ,

 

your needs seem to fall in a case of conditional filtering:

  • to test a single attribute value against some static values and split the flow accordingly (multiple output port), go for the AttributeFilter (this is like a "case" statement);
  • the Tester is useful to split the flow in two streams (passed/failed) based on a set of conditions;
  • the TestFilter can split flow in multiple streams (multiple output port), each of them based on a set of conditions; it's very powerful and highly configurable.

Hope that helps!

 


The closest to SQL "CASE" in FME is using Conditional Values, which is how they are also effectively treated in SQL

https://community.safe.com/s/article/determining-attribute-values-by-testing-with-condi

Conditional Values are most used in AttributeCreator or AttributeManager, which given basically the same analogous function as the top SELECT line in an SQL Statement in creating, naming and calculating fields/attributes, but Conditional Values can be used just about in any Transformer parameter that permits Expressions in FME, and this built in ability to create Logic base Expressions in nearly every Parameter makes FME Transformers extremely flexible.

 

However, in most basic cases you may find it easier to split the Feature streams using AttributeFilter, Tester, TestFilter etc. as per what @davtorgh​ recommends to their separate processing streams or do some more limited, but simpler to implement, CASE statements with with special lookup value<->result value Transformers like AttributeValueMapper or StringPairReplacer.


Reply