<?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: replace null values with 0 in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/1296127#M26899</link>
    <description>&lt;P&gt;This is a very old thread, but the fact that I found this in 2023 means that maybe someone else will also find it now. So, the way to do this on field calculator is:&lt;BR /&gt;&lt;BR /&gt;def rmnull(x):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if x is None:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return x&lt;/P&gt;&lt;P&gt;Hopefully, this helps someone else &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jun 2023 06:53:58 GMT</pubDate>
    <dc:creator>isabelapi</dc:creator>
    <dc:date>2023-06-06T06:53:58Z</dc:date>
    <item>
      <title>replace null values with 0</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/603511#M20037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to replace &amp;lt;Null&amp;gt; values with 0. I have selected these rows by attribute [field] "is null"&amp;nbsp; but can't seem to find a way to actually replace the entries.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can someone tell me how I can replace the values ? I can't just remove the rows, I need the 0 information in them for a field calculation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot !&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 18:42:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/603511#M20037</guid>
      <dc:creator>JulianeStruve1</dc:creator>
      <dc:date>2013-12-27T18:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: replace null values with 0</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/603512#M20038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Did you try and calculate them via the field calculator?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Right-click the column heading and click "Field Calculator..." and in the box write "0" (without the quotation marks).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 18:59:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/603512#M20038</guid>
      <dc:creator>TimWitt</dc:creator>
      <dc:date>2013-12-27T18:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: replace null values with 0</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/603513#M20039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Did you try and calculate them via the field calculator?&lt;BR /&gt;&lt;BR /&gt;Right-click the column heading and click "Field Calculator..." and in the box write "0" (without the quotation marks).&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I did. The field calculator is grayed when I try.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 19:26:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/603513#M20039</guid>
      <dc:creator>JulianeStruve1</dc:creator>
      <dc:date>2013-12-27T19:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: replace null values with 0</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/603514#M20040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I did. The field calculator is grayed when I try.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if you are working on a joined feature class/table you cannot calculate values into the joined table or create records to replace the Null values without first exporting the joined data to a new feature class/table.&amp;nbsp; If that is not applicable what is the data source location and type?&amp;nbsp; How was the data created?&amp;nbsp; Did you create it or are you just trying to access it?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 20:18:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/603514#M20040</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-12-27T20:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: replace null values with 0</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/603515#M20041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The data were joined and the null values are non-matching records.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 20:56:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/603515#M20041</guid>
      <dc:creator>JulianeStruve1</dc:creator>
      <dc:date>2013-12-27T20:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: replace null values with 0</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/603516#M20042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The data were joined and the null values are non-matching records.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There is no record existing to calculate a value into with a non-matching record join, which is why you cannot calculate a value into those (non-existent) records no matter what you might want.&amp;nbsp; The Field Calculator never creates records, it only calculates to existing records.&amp;nbsp; In any case, joins do not allow calculations ever on the joined table, since joins do not exist as real feature classes or tables except in memory which cannot be altered directly with a calculation.&amp;nbsp; (because these joined fields only exist in memory the calculation has no where it can store the value of the calculation to disk and joins do not know if they are in reality based on a 1-1, M-1, 1-M, or M-M relationship).&amp;nbsp; You would have to calculate the value into the original joined table directly to fill in a Null value in any real records.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, in this case you can't even calculate to the original table, since those records do not even exist for you to calculate anything into.&amp;nbsp; You have to create these records somehow.&amp;nbsp; Either you have to insert the unmatched join records into the original join data table so that they are no longer unmatched (and there is no easy way to do that) or you have to export the joined table to create a new table with all of the fields in real no longer joined records so that you can now calculate to the newly created Null fields in an actual table.&amp;nbsp; So use Copy, Feature Class to Feature Class, Copy Features or some similar tool to create a new table from the joined table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Either that or create a calculation that uses the Null values they are with a code block calculation.&amp;nbsp; Something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Parser:&amp;nbsp; VB Script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Use Code Block:&amp;nbsp; Checked&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pre-Logic Script Code&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;If IsNull([JoinedObjectIDField]) Then
&amp;nbsp; Output = "SomeValueWhenRecordsAreUnmatched"
Else
&amp;nbsp; Output = [OriginalValueInOutputField]
End If&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&amp;nbsp; Output&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the ObjectID field of the Joined table in Null the record is unmatched by definition and with the conditional calculation it does not matter if it has a value in it or not since you can process unmatched records differently from the way you process matched records.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:52:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/603516#M20042</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-12T01:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: replace null values with 0</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/1296127#M26899</link>
      <description>&lt;P&gt;This is a very old thread, but the fact that I found this in 2023 means that maybe someone else will also find it now. So, the way to do this on field calculator is:&lt;BR /&gt;&lt;BR /&gt;def rmnull(x):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if x is None:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return x&lt;/P&gt;&lt;P&gt;Hopefully, this helps someone else &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 06:53:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/replace-null-values-with-0/m-p/1296127#M26899</guid>
      <dc:creator>isabelapi</dc:creator>
      <dc:date>2023-06-06T06:53:58Z</dc:date>
    </item>
  </channel>
</rss>

