Case sensitive string comparison
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I am comparing two string fields in a Filter tool and getting unexpected results.
When I use the Filter tool to compare two strings with values of "Extendicare Fort MacLeod" and "Extendicare Fort Macleod" (note the lowercase "L" in the second), the tool returns these as being equal. i.e. [FAC_NAME]==[FAC_NAME_BAD] returns true.
How do I do a string comparison that is Case Sensitive?
Solved! Go to Solution.
- Labels:
- Expression
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Wow @jason_scarlett!
I was unaware of that feature. Here's a sure-fire way to compare:
MD5_ASCII([FAC_NAME])==MD5_ASCII([FAC_NAME_BAD])
Cheers,
Mark
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Perfect, works now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
One more way to skin the cat, because RegEx is almost always a solution too... :)
REGEX_Match([Field1],[Field2],0)
The 0 after the two fields you're comparing indicates that it needs to be Case Sensitive. Leaving that clause out (or having it equal to 1) lets the match become Case Insensitive.
Cheers!
NJ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Please mark @NicoleJohnson as a solution for this post. Her solution is FASTER than mine. I tested hers with 1,000,000 records and RegEx completes the comparison filter in less than 1 second. The conversion to the MD5 hash and evaluation takes roughly 8 seconds.
Cheers,
Mark
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I don't think this will work in the more general case. As regex special characters will cause problems for example '(',')' Since they won't be escaped in a standard string. I think the ASCll Solution is more robust.
Please correct me if i am wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@nicolejohnson Life changing! Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@Di2g10 is right.. regex cannot handle special characters... I would suggest Contains as it has switch for case sensitivity too...
Contains([b], [a],0) AND Length([a]) == Length([b])
or
Contains([b], [a],0) AND Contains([a], [b],0)
//to make it more obvious..
btw. MD5 hash cannot guarantee to have 2 different hashes for every 2 inputs, so it can fail and it is terribly unpredictable (not to mention slow).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I agree this is a better solution to the others proposed (outside of Alteryx fixing what is feel is a bug)
