Skip to main content
Question

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?

  • October 30, 2020
  • 2 replies
  • 291 views

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?
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.

2 replies

davtorgh
Contributor
Forum|alt.badge.img+11
  • Contributor
  • 105 replies
  • November 1, 2020

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!

 


bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • 562 replies
  • November 1, 2020

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.