Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Counting occurences of regex output

crefsgaard
6 - Meteoroid

Hi,

 

I have a dataset consisting of chat conversations between a company and their customers. A chat conversation is stored in one string, in this example we call the customer C112233 and the employee from the company Amalie. A conversation could look like this:

-------------------------------------------

(Amalie): Hi my name is Amalie, how can I help you?

(C112233): I have lost my keys for the house, how can I get a new one?

(Amalie): Let me tell you blablabla..

(C112233): Thank you so much.

(Amalie): No problem, that's what I'm here for, have a nice day.

(C112233): You too

-------------------------------------------

I wish to count the number of messages that the employee writes in some chat conversation with a customers. I have tried something with the Regex tool, e.g: (\(\w+\)):\s in order to find the messages that the employee writes. Any idea of how I can sum this number of occurences, i.e. how can I sum the number of times that (Amalie) occures in the string? It is important for me to emphasize that the company has several employees, not only Amalie, and I want this to work with any employee name.

 

Thank you in advance!

4 REPLIES 4
MarqueeCrew
20 - Arcturus
20 - Arcturus
How about:

Regex_countmatches([chat],"\(\w{3,}\)")

That would look for a paren open followed by 3 or more word charters followed by a close paren.
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
MarqueeCrew
20 - Arcturus
20 - Arcturus
Regex_countmatches([chat],"\(\u\l+\)")

That checks for open paren followed by an uppercase letter followed by one or more lowercase letters followed by a close paren.
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
crefsgaard
6 - Meteoroid

Thanks for a quick reply. I solved the counting issue like you suggested:

 

REGEX_CountMatches([Chart], "\(\D+\)").

 

Now that I have the number of messages from the employee, do you have any suggestion to how I can count the total number of words written by the employee? Let's say I got a total of 3 messages by the above formula, and say that each message contains 10 words. How to I accumulate this and get the total of 30 words written?

 

Thanks!

MarqueeCrew
20 - Arcturus
20 - Arcturus

As a solution solve...

 

  1. Input Data
  2. Add RecordID
  3. Parse Text on newlines to Rows
  4. Filter Rows where employee name exists
  5. Count words minus name for each employee remark
  6. Sum words per original record for employee words

Capture.png

 

Hopefully this solves the thread.

 

Thanks,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Labels