Split by attribute in Model Builder

6433
11
Jump to solution
06-18-2015 07:12 AM
JonathanMori1
New Contributor III

Hi,

I have been attempting this model but I am having a little trouble with one part. The model exports from a SQL Spatial Database using Data Interop Extension , and merges them into one feature class. The problem I am having is that it needs to be split into separate shapefiles based on the "layer" field. I did some research and found that  "Iterate Field Values" would be able to do this, but I cannot get it to work right. I attached the toolbox and the Model that I am referring to is M4ExportModel_Points2. I was wondering if anyone could see what I'm missing or what I am doing wrong.

0 Kudos
1 Solution

Accepted Solutions
SepheFox
Frequent Contributor

I'm assuming it just stops at the iterator. I just noticed the problem. After the iterator you need to insert Select by Attribute, and use the Value variable in your selection query, then you can connect that to copy features.

View solution in original post

0 Kudos
11 Replies
SepheFox
Frequent Contributor

Can you just put in a screenshot of your model? It is much easier than downloading a zip, etc.

0 Kudos
JonathanMori1
New Contributor III

OK, here is the section after the merge where I am trying to split by attributes. The Expression is ("Layer"=%Value%)

9tAAtK9.jpg

SepheFox
Frequent Contributor

You didn't mention what happens when you run the model, but try replacing Feature Class to Feature Class with Copy Features.

0 Kudos
JonathanMori1
New Contributor III

OK Here is the Iterator part I'm having issues with. It runs fine up until then

Executing (Iterate Field Values): IterateFieldValues C:\Users\morij\Desktop\Projects\M4Testing_062015\ModelTest\M4ExportMerge_PointUTM Layer Long true true 0

Start Time: Thu Jun 18 10:56:31 2015

Succeeded at Thu Jun 18 10:56:31 2015 (Elapsed Time: 0.01 seconds)

0 Kudos
SepheFox
Frequent Contributor

I'm assuming it just stops at the iterator. I just noticed the problem. After the iterator you need to insert Select by Attribute, and use the Value variable in your selection query, then you can connect that to copy features.

0 Kudos
JonathanMori1
New Contributor III

What I had to do is create another model, because I got it somewhat working, but it would go through whole the model again for each iteration and take forever.  The new one only has the "Iterate Feature Selection" as seen below, it uses the export/merge/projected shapefile from the other model.

This seems to be working pretty well.

0 Kudos
SepheFox
Frequent Contributor

Great! You can make a submodel out of this and put it in your larger model.

JonathanMori1
New Contributor III

I am trying the copy features tool as you suggested and Iterate Feature Selections with a "group by" Layer

0 Kudos
DanPatterson_Retired
MVP Emeritus

If you feel like splitting it up as a separate process see Split Layer By Attribute (for version 10.3, a toolbox can be generated for older versions if needed)

0 Kudos