Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Count # of occurance of field across columns

hal_dal
8 - Asteroid

Hi,

 

I have a specific condition that I'm struggling with and wondering if anyone is able to help.

 

I have a set of input data as below:

(I have a bunch of date in that Date field (repeating multiple times) and ID field that also repeats multiple times

 

Project IDDateStatus
:0002740811/7/2019 
:0002740811/14/2019 
:0002740811/21/2019 
:0002740811/28/2019 
:0002740812/5/2019Not Rated
:0002740812/12/2019Not Rated
:0002740812/19/2019Not Rated
:000274081/9/2020Not Rated
:0003527611/7/2019Not Rated
:0003527611/14/2019Not Rated
:0003527611/21/2019Not Rated
:0003527611/28/2019Not Rated
:0003527612/5/2019Not Rated
:0003527612/12/2019Not Rated
:0003527612/19/2019Not Rated
:000352761/9/2020Not Rated
:0003725311/7/2019Not Rated
:0003725311/14/2019Not Rated
:0003725311/21/2019Not Rated
:0003725311/28/2019Not Rated
:0003725312/5/2019Not Rated
:0003725312/12/2019Not Rated
:0003725312/19/2019Not Rated
:000372531/9/2020Not Rated
:0003726311/7/2019Not Rated
:0003726311/14/2019Not Rated
:0003726311/21/2019Not Rated
:0003726311/28/2019Not Rated
:0003726312/5/2019Not Rated
:0003726312/12/2019Not Rated
:0003726312/19/2019Not Rated
:000372631/9/2020Not Rated
:0003880411/7/2019Yellow
:0003880411/14/2019Yellow
:0003880411/21/2019 
:0003880411/28/2019Yellow
:0003880412/5/2019Yellow
:0003880412/12/2019Yellow
:0003880412/19/2019Yellow
:000388041/9/2020Yellow
:0003983611/7/2019 
:0003983611/14/2019Not Rated
:0003983611/21/2019Not Rated
:0003983611/28/2019Not Rated
:0003983612/5/2019Not Rated
:0003983612/12/2019Not Rated
:0003983612/19/2019Not Rated
:000398361/9/2020Not Rated



I initially had to use transpose to get the date field turn into their own columns and Status field as their records (which Im able to do successfully)

then i was asked to also count the number of occurance/frequency of the "Yellow" from that status field. (Only when there's Yellow in consetutive rows and no other values appear in between, if there is (like my example below, then it will start counting for Yellow again)

 

 

I need to also figure out how many times that Yellow was repeated for the particular ID in the particular date.

 

Below is the expected results:

 

Project IDW11/7/201911/14/201911/21/201911/28/201912/5/201912/12/201912/19/20191/9/2020
:000274080    Not RatedNot RatedNot RatedNot Rated
:000352760Not RatedNot RatedNot RatedNot RatedNot RatedNot RatedNot RatedNot Rated
:000372530Not RatedNot RatedNot RatedNot RatedNot RatedNot RatedNot RatedNot Rated
:000372630Not RatedNot RatedNot RatedNot RatedNot RatedNot RatedNot RatedNot Rated
:000388045YellowYellow YellowYellowYellowYellowYellow
:000398360 Not RatedNot RatedNot RatedNot RatedNot RatedNot RatedNot Rated

 

you will see in the example for ID 00038804 that Yellow counts as 5 rather than 7 because there was a blank (or could be any other values) in between it.

 

Please let me know if my explanation is confusing.

Thanks in advance!

21 REPLIES 21
hal_dal
8 - Asteroid

@AbhilashR 

I'm not very familiar with generate row field. But would I just use the summarize took to find the min and max?(would these be in one summarize or two?) And how would I apply these to the generate tool? 

Sorry for asking a lot of questions!

And thank you so much for all the help 

AbhilashR
15 - Aurora
15 - Aurora

Hi @hal_dal, further looking at your data I realized Generate Rows won't be a good fit (since you don't have continuous dates). Instead I think what you are looking for is to bring it empty rows for IDs with missing dates, correct? e.g. :00033559 only has one date row and you are looking to introduce additional dummy rows for the dates it is missing. If yes, in the attached approach I compute unique dates and IDs and append them to each other to produce a universe that has every possible combination of ID + Date. This is then joined back to the original dataset to fill-in the missing gaps in data. The rest of the workflow is the same as the previous proposals.

 
 

Capture.PNGDoes this get you that much closer to your destination state? Please feel comfortable asking as many questions as you need.

Labels