Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

Alteryx Designer Desktop Discussions

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

counting distinct using REGEX_Countmatches....

Raj_007
8 - Asteroid

Hi All, Thanks for your time,

I have a field with values that are seprated by the comma or , - when I try to count the distinct values in that using the REGEX_CountMatches it is not doing the DISTINCT

did I miss anything

 

Field1                CountColumn

xyz                         1

abc, xyz                  2

abc,xyz,MMM          3

abc,xyz,abc             2     - This should be 2 since abc is repeating

 

What I have is 

CountColumn=REGEX_CountMatches([Field1], ",") + 1

6 REPLIES 6
Yoshiro_Fujimori
15 - Aurora

Hi @Raj_007 ,

It seems your expression counts the number of comma, and it does not count distinct values.

I do not know if RegEx can serve for your case.

 

So I split the items between the separators and used Count Distinct in Summarize tool.

I hope it works.

 

Workflow

Community_1195217.png

Qiu
21 - Polaris
21 - Polaris

@Raj_007 
I agree with @Yoshiro_Fujimori and use the same flow. 😁
Your regex is simply counting the occurence of character "," not the unique string.

flying008
14 - Magnetar

Hi, @Raj_007 

 

Another way like @Yoshiro_Fujimori  for you.

 

录制_2023_10_07_09_28_01_592.gif

Raj_007
8 - Asteroid

Hi Thank you so much. This is really helpful -  noticed that ths approach works when i know the list of values - meaning it can be 1 or 2 or 3 or 4 or 5 - I dont know how many values in the form of abc,XYZ,MMM 

how did you get only column in Text TO Columns Field (FIeld1) - text to columns will break each value into each column right? how did you get only 1 column

Raj_007
8 - Asteroid

I think i see what you have done - split to rows - when you count distinct for  each value or for each ID - how do we attach that count distinct number to the Record ID

I am getting an error message in Find and Replace Tool  - I just want to join the output of the count distinct number to the main dataset - should we use join tool or 

find and replace will work?

 

 

 

Raj_007
8 - Asteroid

Find and Replace only works with strings - I was trying to replace the value of 0 which is a calculated column to be replaced the count distinct value that is coming from the summarized tool

if i change the data type to string then i can see the column name in it - but it is still showing zero only

 

Labels