As you read this, chances are that I’ve already reached my secure, undisclosed Thanksgiving holiday destination. I still haven’t finished packing, so I’ll try to make this post brief. This week, “R.” in Butler, MO, writes:
Dear Feed Doctor,
I’m trying to write a business rule that does certain things when my item’s brand attribute is “Acme.” I know I’m going to use an IF function, but I’m struggling with writing the condition part. There are several ways to look for “Acme” in a field; what’s The Best Way?
Well, “R,” it really depends on the possible variations of “Acme” that you might have. Let me give you some guidelines:
- If it’s always “Acme” and just “Acme,” then you can just use an equal sign:
$brand="Acme"
- If the “Acme” text could be surrounded by some other text, like “The Acme Company,” then you can use CONTAINS:
CONTAINS($brand,"Acme")
- If the “Acme” text could have some other characters sprinkled through it, like “Ac-me,” then you probably should use a regular expression:
REGEXMATCH($brand,"Ac-?me")
One final note: ALL of those methods are case sensitive. If it’s possible that you might sometimes have “ACME,” you could try converting your brand to all lower-case and then using one of the three methods, like this:
- TOLOWER($brand)=”acme”
- CONTAINS(TOLOWER($brand),”acme”)
- REGEXMATCH(TOLOWER($brand),”ac-?me”)
Don’t forget to change your comparison strings to all lower-case, too!
That’s all for now. And also, even though the year is winding down, we’re busier than ever in the Code Factory, so I’m afraid I probably won’t get very many more posts up before 2008. Happy Thanksgiving to you all!
Share This