Getting latest data out of a data set.

10-01-2015 05:31 AM
New Contributor III

I am working with some data for property leases in Texas, some of the areas have historic data where it will show all of the owners of the property so when i try and label it some areas will have several names over them. I need to get it to ownly show the newest set of data for each property. The data has an expiration date on the lease for each owner and the leases are connected through a common FID. I was thinking about trying to a definition query to get the latest data out but I cant think of a way that it would work. Any help would be REALLY appreciated.



0 Kudos
5 Replies
New Contributor III

Or maybe a simpler way of putting it, would be that for Each FID I need it to show the owner name associated with the newest date

0 Kudos
Esri Esteemed Contributor

Hi Robert,

If all of the attributes are contained with the property leases feature class, you can run a Dissolve.  You will want to specify the FID field to dissolve on and the Date field as a MAX statistic.  Ex:


New Contributor III

Is there a way to do this but to keep the other fields with the data? this is working to get the FIDs that I need but then I lose the Owner of the lease.

0 Kudos
MVP Honored Contributor

Dissolve by both Owner and FID. This will merge together all unique combinations of Owner and FID.

Occasional Contributor III

You could probably create a python script go through the data and set a flag (in a new field) that indicates which is the active lease feature.

Depending on your data source, you can use arcpy.da.UpdateCursor and order the results by FID and date using an ORDER BY in the SQL clause.

eg. sql_clause=(None, 'ORDER BY FID, EXPIRY_DATE DESC')

Then loop through the rows of the resulting cursor and set the flag only for the first record of each FID.

This way you can either use the resulting flag in a definition query on the layer to show only active leases on the map, or you can use it to create a label class in the labelling properties so that only active leases get labelled.