Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Check alphabetical repetitions count

tarun_kumar10
7 - Meteor

I have two output 

1- Navneet 

2- Aeetmmmr

 

How I can  get the count of alphabetical repetitions. 

OutPut Like - Navneet - 2 because e comes two times or Aeetmmmr , e comes two  times and m comes three times 

3 REPLIES 3
Gaurav_Dhama_
8 - Asteroid

For this very specific case, you can use the below formula.

 

REGEX_CountMatches([Name], "m")

 

You can replace "m" with the letter of your choice. For example, if you use the below formula, you will get 1 match for Aeetmmmr.

 

REGEX_CountMatches([Name], "mr")

 

However, in case you want to check how many times m and r independently appeared in a string, you can use the below formula.

 

REGEX_CountMatches([Name], "[mr]")

 

Any letter you put inside [] will be checked independently, i.e. 

 

If this solves your ask, please mark this as the solution.

LindonB
8 - Asteroid

If your goal is simply to get a count of duplicate characters within each word, consider using the \1+ expression in regex, as it checks against the previous character. In the attached workflow, I've added a formula that demonstrates this. It sums two REGEX_CountMatches functions, one to count the repeated characters and one to count to original character that is repeated. 

 

REGEX_CountMatches([word], '(?=(.)\1)') + REGEX_CountMatches([word], '(?<=(.))(?!\1)(.)\2'  

 

Output:

1.PNG

 

 

 

 

 

You can adjust this to search for only letters by replacing (.) if needed, and this will check only within whole words if you apply it to a phrase. 

 

If your goal is instead to return counts for each consecutive substring (and you want to also list out the substrings), there's a few approaches. The workflow walks you through a multirow formula approach. It generates a row for each letter though, so it might not scale well if you feed it a lot of data.

 

Output:

2.PNG3.PNG

Qiu
20 - Arcturus
20 - Arcturus

@tarun_kumar10 
There is also another way as below rather than RegEx.
This approach is to tokenize each alphabet then do the count.

And we need to also think if it is consecutively count or not.

0519-tarun_kumar10.png

 

Labels