<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to calculate maximum value of different columns integrated in if else statement? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-calculate-maximum-value-of-different/m-p/61685#M4918</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;Thank you very much for your help!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 05 Jan 2019 17:54:11 GMT</pubDate>
    <dc:creator>VerenaSarwas</dc:creator>
    <dc:date>2019-01-05T17:54:11Z</dc:date>
    <item>
      <title>How to calculate maximum value of different columns integrated in if else statement?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-calculate-maximum-value-of-different/m-p/61681#M4914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;Hey guys,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;hopefully you all started the new year well!&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;My problem is as follows (by the way I am new in programming with python in GIS):&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;There are 5 different slope-classes for my GIS analysis. The attribute table shows how many points per area belong to a certain slope-class (Example: Area 1: Slope 1 - 10 points, Slope 2 - 20 points, Slope 3 - 30 pints, Slope 4 - 10 points, Slope 5 - 0 points). In the table there are a hundred different areas, each row represents one area.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;The goal is to determine a slope tendency for each area. The idea was to calculate the maximum of the different counted slope points for each area and then say that for example area 1 has a slope tendency of 3.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;I tried to make an ifelse statement with integrated max function in the field calculator&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;EM style="color: #3d3d3d; font-size: 11.5pt;"&gt;Pre-logic script code:&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;def Ergebnis (!Join_Count_1!, !Join_Cou_2!, !Join_Cou_3!, !Join_Cou_4!, !Join_Cou_5):&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;if Join_Count_1 = max([!Join_Count_1!, !Join_Cou_2!, !Join_Cou_3!, !Join_Cou_4!, !Join_Cou_5!]):&lt;BR /&gt; return "1"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;elif Join_Cou_2 =&amp;nbsp;max([!Join_Count_1!, !Join_Cou_2!, !Join_Cou_3!, !Join_Cou_4!, !Join_Cou_5!]):&lt;BR /&gt; return "2"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;elif Join_Cou_3 =&amp;nbsp;max([!Join_Count_1!, !Join_Cou_2!, !Join_Cou_3!, !Join_Cou_4!, !Join_Cou_5!]):&lt;BR /&gt; return "3"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;elif Join_Cou_4 =&amp;nbsp;max([!Join_Count_1!, !Join_Cou_2!, !Join_Cou_3!, !Join_Cou_4!, !Join_Cou_5!]):&lt;BR /&gt; return "4"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;elif Join_Cou_5 =&amp;nbsp;max([!Join_Count_1!, !Join_Cou_2!, !Join_Cou_3!, !Join_Cou_4!, !Join_Cou_5!]):&lt;BR /&gt; return "5"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;else&lt;BR /&gt; return "No Data"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;EM style="color: #3d3d3d; font-size: 11.5pt;"&gt;Expression:&lt;/EM&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #3d3d3d; font-size: 11.5pt;"&gt;max([!Join_Count!, !Join_Cou_1!, !Join_Cou_2!, !Join_Cou_3!, !Join_Cou_4!])&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt; &lt;BR /&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #3d3d3d; font-size: 11.5pt;"&gt;When I am running the field calculator I always get a python syntax/parsing error. In a different version of this code I also got the indentation error in python.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt; &lt;BR /&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #3d3d3d; font-size: 11.5pt;"&gt;Could somebody please help me and state where my errors are respectively show me where my way of thinking is wrong?? Maybe there are alternatives how to solve this problem????&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt; &lt;BR /&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm; margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #3d3d3d; font-size: 11.5pt;"&gt;Thank you very much in advance!!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Jan 2019 14:44:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-calculate-maximum-value-of-different/m-p/61681#M4914</guid>
      <dc:creator>VerenaSarwas</dc:creator>
      <dc:date>2019-01-05T14:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate maximum value of different columns integrated in if else statement?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-calculate-maximum-value-of-different/m-p/61682#M4915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In your pre-logic code, don't use exclamations around your variable definitions.&amp;nbsp; The exclamations are for when you are passing the fields as arguments to your function, not as variables within your function.&amp;nbsp; For example:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; Ergebnis &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;JC1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; JC2&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; JC3&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; JC4&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; JC5&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; JC1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; max&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;JC1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; JC2&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; JC3&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; JC4&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; JC5&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"1"&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;elif&lt;/SPAN&gt; JC2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; max&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;JC1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; JC2&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; JC3&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; JC4&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; JC5&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"2"&lt;/SPAN&gt;
 
&lt;SPAN class="comment token"&gt;# fill in remaineder code&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"No Data"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, for your expression, you want to call your function, otherwise your code will never be executed:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 11.5pt;"&gt;Ergebnis(!Join_Count!, !Join_Cou_1!, !Join_Cou_2!, !Join_Cou_3!, !Join_Cou_4!)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:20:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-calculate-maximum-value-of-different/m-p/61682#M4915</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-10T22:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate maximum value of different columns integrated in if else statement?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-calculate-maximum-value-of-different/m-p/61683#M4916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Ergebnis&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; b&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; c&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; d&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; e&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="string token"&gt;"""return the maximum of the 5 columns"""&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; m &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; max&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; b&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; c&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; d&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; e&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; a&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;index&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;max&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#expression&lt;/SPAN&gt;
Ergebnis&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;!Join_Count!&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;!Join_Cou_1!&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;!Join_Cou_2!&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;!Join_Cou_3!&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;!Join_Cou_4!&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;sample on a list&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt; a &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
a&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;index&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;max&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
&lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="comment token"&gt;# --- index of the max, counting from 1&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:20:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-calculate-maximum-value-of-different/m-p/61683#M4916</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-10T22:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate maximum value of different columns integrated in if else statement?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-calculate-maximum-value-of-different/m-p/61684#M4917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for your help! It worked nicely.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Jan 2019 17:53:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-calculate-maximum-value-of-different/m-p/61684#M4917</guid>
      <dc:creator>VerenaSarwas</dc:creator>
      <dc:date>2019-01-05T17:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate maximum value of different columns integrated in if else statement?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-calculate-maximum-value-of-different/m-p/61685#M4918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;Thank you very much for your help!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Jan 2019 17:54:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-calculate-maximum-value-of-different/m-p/61685#M4918</guid>
      <dc:creator>VerenaSarwas</dc:creator>
      <dc:date>2019-01-05T17:54:11Z</dc:date>
    </item>
  </channel>
</rss>

