community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx Designer Knowledge Base

Definitive answers from Designer experts.
#SANTALYTICS

The highly anticipated Alteryx Community tradition is back! We hope you'll join us!

Learn More

How To: Split Output Into Multiple Files with Specific Record Counts

Moderator
Moderator
Created on

How To: Split an Output into Multiple Files with Specific Record Counts

 

Sometimes, you may want to write data to multiple files, with each file containing a specific number of records. You can leverage a Record ID column to do exactly that!

 

Procedure

 

  1. Add a Record ID tool at the end of your workflow and leave the default settings

  2. Add a Formula tool
    1. Add a new field called 'GroupID' and change the type to Int32
    2. In the Expression box, type in the formula below, replacing 25 with your desired number of records per file
       CEIL([RecordID]/25)
  3. Add an Output tool
    1. At the bottom of the Configuration window, check the box that says 'Take File/Table Name From Field'
    2. Leave the option 'Append Suffix to File/Table Name'
    3. Select the GroupID field in the 'Field Containing File Name...' and choose whether or not you want to 'Keep Field in Output'

A sample workflow is attached.

Attachments
Comments
Asteroid

Big relief,  1000 STARS to this post.

Meteoroid

This is helpful. Thanks !

 

Alteryx
Alteryx

This just saved me a bunch time @DanC!

 

 

Moderator
Moderator

Great, @KylorI! Glad to hear it!

Asteroid

Hi... Appreciate for this time-saving solution.

 

In addition to this I want to split the records into separate sheets based on a record count with a dynamic file name.

 

For example I have records which need to go to different files based on an input column, say City

(each file will have separate sheets with the # of records I set using Group ID).

 

I already use a variable FileName which has "C..\.."+[City] which I use in Change Entire FilePath.

Within each city how to split into different sheets based on Group ID?

Meteoroid

In my project I have a column of the name of individuals, these individuals each have a different number of flags.

Instead of putting 25, how do you go about putting the number of flags each person has correspondingly?

Atom

Hello,

 

I have a bit of a twist on this.

 

I have a summarized data set that shows an account and the number of transactions they had. My goal is to split this set of 90,727 accounts as evenly as possible based on 2 factors; # of Accounts as well as sum of transactions for the set.

 

Not sure of how to go about doing this. One of these variables is obviously easy but splitting as evenly as possible based on record count and sum of their transactions I am unsure in a perfect world based on my data the breakdown would be 3 sets of ~30242 Accounts and ~5,886,395 Transactions as I have 90,727 Accounts and 17,659,185 Transactions between them.

 

Thanks!

 

 

Thanks @DanC ! Saved me a lot of time.

Meteor

I have a similar problem. Need to split my data into separate files by the state field. This would be easy except each file needs to have a header and trailer record.  The trailer should contain a count of records within the file.  Not sure if this is possible but would like to avoid saving the workflow 50 times to account for each state.  Currently the workflow builds a file that looks like this.  

 

Example:

HDR#############

BDY#############|| CA

BDY#############|| NY

BDY#############|| AL

TRL#############[count]

 

Any suggestions?