I have a dataset with co-located points (e.g. "Site 1" has 3 rows with different numbers in the Value field).
I need to label the site with the max value of the set (the highlighted values below).
Here is a solution using python based on Label highest values and How To: Label a related table
<SPAN class="keyword token">import</SPAN> arcpy lyrName <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'path\to\layer'</SPAN> <SPAN class="keyword token">def</SPAN> <SPAN class="token function">getMax</SPAN><SPAN class="punctuation token">(</SPAN>location<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> filter <SPAN class="operator token">=</SPAN> f<SPAN class="string token">"Location_Name = '{location}'"</SPAN> <SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>lyrName<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Value'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> where_clause<SPAN class="operator token">=</SPAN>filter<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> cursor<SPAN class="punctuation token">:</SPAN> max_val <SPAN class="operator token">=</SPAN> max<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> cursor<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">return</SPAN><SPAN class="punctuation token">(</SPAN>max_val<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">def</SPAN> FindLabel <SPAN class="punctuation token">(</SPAN> <SPAN class="punctuation token">[</SPAN>Location_Name<SPAN class="punctuation token">]</SPAN> <SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">return</SPAN> getMax<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>Location_Name<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
You use a search cursor to find the maximum of all 'Value' for the records where 'Location_Name' matches the Location_Name for the current feature. Be sure to replace the path to your layer (it must be the full path to the data on disc). Since it is reading the data from disk it will not honor things like definition queries so watch out for that. You may also want to disable duplicate labels for the layer.
If you end up using the techniqueElliott Kurtz references/proposes, just be aware it will not perform well for large data sets, and it might not even perform well for moderate data sets. If the data isn't changing often, I suggest you create a new column in the data set and populate with the label value rather than generating it dynamically each time the screen is refreshed.
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.