Alteryx Designer Desktop Discussions

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

Unique Count

dataguy
7 - Meteor

 

Hi All,

 

I am trying to transform the data below (please see both tables). I am able to get the first two columns in the transformed table by using group by and distinct count. I am unable to come up with a clean logic to get column 3. Can you help?

 

Data:

 

ID1ID2ID3
A11
A11
A20
A20
A31
A31
A31
A40

 

Transformation:

 

 

ID1ID2ID3
A42

 

7 REPLIES 7
jdunkerley79
ACE Emeritus
ACE Emeritus

I would suggest transposing, summarising and cross tabbing to get distinct.

 

Quick sample attached

dataguy
7 - Meteor

Thanks so much for your quick response. I really appreciate it. My apologies for providing incomplete information. Let me provide the additional columns and that should help you formulate the complete solution. There are some columns on which I want to do a count distinct and on some columns sum.

 

Data:

 

A. IDB. IDC. IDD. IDE. NumF. Num
X111100200
X111100200
X220200300
X220300400
X311500600

 

Transformation:

 

A. IDB. IDC. IDD. IDE. NumF. Num
X32212001700

 

In this case, the column D. ID was the one for which you provided the solution.

 

A.ID  -> Group BY

B.ID -> Count Distinct Not Null

C. ID -> Count Distinct Not Null

D. ID -> ??? some combination of transpose and cross tab ???

E.ID -> Sum

F. ID -> Sum

danrh
13 - Pulsar

You should be able to do this with only the Summarize tool:

 

image.png

 

Count Distinct on column D isn't giving you 2 in this situation?  See attached and let me know if I've set something up differently than you have it.

jdunkerley79
ACE Emeritus
ACE Emeritus

@danrh has provided the much simpler solution! 

 

If you have dynamic sets of columns then my approach would work but if you have known set, then his is better.

 

If you do need to cope with different sets then you can use filter tools to aggregate with different methods. Happy to put a sample together if useful.

 

dataguy
7 - Meteor

Thanks for the reply. I changed the data set to better illustrate this example. The calculation of D.ID is linked to B.ID. Essentially, D.ID is a flag ( 1 or 0) that contains information about B.ID. However, I want to sum the D.ID for every B.Id only once. For example, B.ID shows up four times. However, I want D.ID to show 3 because only three B.ID have value. I would appreciate a sample workflow.

 

Data:

 

A. IDB. IDC. IDD. IDE. NumF. Num
X10100110002000
X10100110002000
X10500110002000
X20200020003000
X20200030004000
X30300150006000
X40400160007000

 

Transformation:

 

A. IDB. IDC. IDD. IDE. NumF. Num
X4531900026000
jdunkerley79
ACE Emeritus
ACE Emeritus

You will have to compute the D.ID value separately and then join it back together.

 

2017-09-28_22-33-51.jpg

Sample attached

dataguy
7 - Meteor

Thanks!

Labels