Python or Model Builder

4535
22
11-13-2014 07:51 AM
RickWarner
New Contributor III

I have developed a model that the first step is to select records for a table with field name Sales, I manually now change sql expression from Sale 1 to Sale 2 etc, there are about 50 groups of sales. Once the  group is selected, it then is joined with a polygon feature Parcels, records copied, join removed and then onto the next group of sales (There are upto 50 sales for each parcel, so a simple join doesn't work,)

I would like to automate the sql expression that initially selects the records,  so that once the first group of sales is copied, join removed,  the table then selects the next group of sales.  Also I need a way to change the name of the copied features to match the sales group, so it doesn't overwrite.

The model works fine now, except that I must manually change the sql expression after each sale group and change the copied features name so it doesn't overwrite the previous sales group.

How can I automate the sql expression, if that is the appropriate approach?

Thank you.

Tags (2)
0 Kudos
22 Replies
RickWarner
New Contributor III

Thanks Josh, I appreciate your help, I got that fixed, but now I'm hung up on table view, the way it is running now, each tableview is being overwritten by the next tableview, there are 20 or so groups of sales. I would like to join each tableview to a parcel map, copy those feature to a new file, then go on to the next sale group/table view. How would you suggest. MakeFature_management didn't work because I'm starting with a table.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

It is easier to look at code and provide feedback than statements describing the code.  What code are you using to build the table views?

0 Kudos
curtvprice
MVP Esteemed Contributor

I have developed a model that the first step is to select records for a table with field name Sales, I manually now change sql expression from Sale 1 to Sale 2 etc, there are about 50 groups of sales. Once the  group is selected, it then is joined with a polygon feature Parcels, records copied, join removed and then onto the next group of sales (There are upto 50 sales for each parcel, so a simple join doesn't work,)

This kind of iteration should be pretty easy to do in ModelBuilder using Iterate Row Selection

You can set up a processing chain to do all these things on each iteration, including adding a join, doing the copy, and removing the join. You sometimes have be very careful using preconditions to make sure the tools in the proc chain run in the right order.

Also I need a way to change the name of the copied features to match the sales group, so it doesn't overwrite.

This is done in ModelBuilder by using a model builder variable to uniquely name the outputs by embedding a variable name in the output table of your copy rows -- for example: out_poly%n% -- %n% is a built in model variable that is the model iteration count (0,1,2...)

0 Kudos