-
1. Re: Count characters/letters in a string
Matt LuttonMar 10, 2014 9:44 AM (in response to Douglas Manning)
I tried everything I could to make this work, but couldn't ever get a solution within Tableau. That doesn't mean it isn't possible, but I sure couldn't find a way.
-
2. Re: Count characters/letters in a string
Tom WMar 10, 2014 9:45 AM (in response to Douglas Manning)
1 of 1 people found this helpfulYou can achieve this by finding the length of the string then subtracting the length of a string where you've replaced the the characters you're trying to find with nothing and divided by the length of the characters you're trying to find:
(len([Fullname])-len(REPLACE([Fullname],[findstr],"")))
/ len([findstr])
-
3. Re: Count characters/letters in a string
Matt LuttonMar 10, 2014 9:53 AM (in response to Tom W)
Tom: I am unable to follow your logic--can you provide an example? Simply copy and paste "John Doe" as a record into Tableau, and apply your solution so we can see it working. I'm not able to follow what you are suggesting here.
-
4. Re: Re: Count characters/letters in a string
Tom WMar 10, 2014 9:56 AM (in response to Matt Lutton)
My formula above was the example. Substitute Fullname with the field you're searching, and findstring with the string you want to find.
I've attached a workbook example.
-
findstring.twbx 13.7 KB
-
-
5. Re: Count characters/letters in a string
Matt LuttonMar 10, 2014 10:04 AM (in response to Tom W)
Thanks for clarifying--this is great! It would be wise to use the UPPER or LOWER value of the string you are searching for, so case sensitivity is not an issue.
-
6. Re: Count characters/letters in a string
Douglas Manning Mar 10, 2014 10:08 AM (in response to Matt Lutton)Tom: Awesome work... I knew there was a way!
Matthew: Thanks for the tip!