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.
SOLVED

Filter out duplicate records with a blank value unless it's the only record

StephenJPSheehan
7 - Meteor

Hello,

 

I'm looking to filter out records in my data that have a blank value in one column "Name", but only if the record is a duplicate the "RecordID" field. For example:

 

RecordIDNameValue
5105040000
612112370815
613112766510
61417653044
6158305757
616485695
61721201225
618182425
1  
5  
61  

 

In the above extract, I would want to keep the first record for where "RecordID" = 5 ("Name" = 10) and remove the blank record where "RecordID" = 5. However, for "RecordID" = 61, I want to keep all records except for the last blank record. Finally, there is only one record for "RecordID" = 1, and I want this to be kept and not removed.

 

Appreciate any advice you may have with helping solve this problem!

5 REPLIES 5
joshuaburkhow
ACE Emeritus
ACE Emeritus

@StephenJPSheehan This is a good one! Haven't seen a question like this in a while 😉

 

I would probably go down the route of sorting by id and name then running a group Record ID (https://gallery.alteryx.com/?ref=downloads#!app/CReW-GroupByRecordID/5e417bbf0462d70decb763a9) to get the counts of each and then simply a filter to say only keep '1's. That seems like it should do it

Joshua Burkhow - Alteryx Ace | Global Alteryx Architect @PwC | Blogger @ AlterTricks
Qiu
21 - Polaris
21 - Polaris

@StephenJPSheehan 
Hope this is what you need.

1230-StephenJPSheehan-1.PNG

Emil_Kos
17 - Castor
17 - Castor

Hi @StephenJPSheehan,

 

I have prepared a workflow for you:

 

Emil_Kos_0-1609328732896.png

To explain a little bit first I used summary tool + join tool in order to add information about how many times this record ID occurred in the data.

 

Second and most important is the multi row tool:

 

IIF([RecordID]=[Row-1:RecordID]
AND [CountDistinct_Name]>1
AND IsEmpty([Name])
, 1, 0)

 

I am checking if the previous record ID is exactly the same. At the same time, I want to check if this isn't the unique value and if the column empty isn't empty. 

 

Thanks to this formula I am able to add a flag that will allow me to remove unnecessary data. 

My final output:

Emil_Kos_0-1609329006292.png

 

StephenJPSheehan
7 - Meteor

Thanks Emil - this solution worked perfectly!

StephenJPSheehan
7 - Meteor

Thanks Qiu - this solution worked great for me. I tried Emil's first which also worked, but your solution also works.

Labels