<?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: Using &amp;quot;If&amp;quot; formula sometimes returns blank cells in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Using-quot-If-quot-formula-sometimes-returns-blank-cells/m-p/46789#M26653</link>
    <description>&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Uncharted/If-Secrets/ba-p/39558" target="_blank"&gt;Here's&lt;/A&gt; a blog on &lt;STRONG&gt;if&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Discussions/floating-number-error-with-a-simple-substraction/m-p/35822#M21130" target="_blank"&gt;Here's&lt;/A&gt; a previous question about representing base-10 decimal numbers in binary floating point. The short answer is a number like .1 or .2 is represented in binary much like 1/3 is in base 10: an infinite repeating sequence of digits. It gets truncated at some point, and rounded, and&amp;nbsp;might be slightly large or slightly small. (&lt;EM&gt;slightly&lt;/EM&gt; is about 1e-15). In the same way that .333+.333 != .667, .1+.2 !=.3&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;.1+.2==.3
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;0 // &lt;EM&gt;why not? subtract them and see why they are different&lt;/EM&gt;...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;(.1 + .2) - .3
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;5.55111512312578e-17 // &lt;EM&gt;that's a really small difference&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;This is not specific to JMP; see the Excel comment in the second link above.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending how Total_money was calculated, the value&amp;nbsp;near 259.85 may be 259.8500..01 or 259.8499..99 (roughly) and you might want your if statement to split the pennies at the half-way point (untested code, approximately right):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// caution: counting pennies using floating point will be painful!
if( total_money &amp;gt; 259.845, "5", // 259.85 and above
total_money &amp;gt; 139.895, "4", // 139.90 and above
total_money &amp;gt; 89.845, "3", // 89.85 and above
...
"0") // none of the above&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The &lt;EM&gt;if&lt;/EM&gt; does each test in order and uses the first true answer. The final "0" answer has no test and is the &lt;EM&gt;else&lt;/EM&gt; clause of the if statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 05 Nov 2017 23:31:59 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2017-11-05T23:31:59Z</dc:date>
    <item>
      <title>Using "If" formula sometimes returns blank cells</title>
      <link>https://community.jmp.com/t5/Discussions/Using-quot-If-quot-formula-sometimes-returns-blank-cells/m-p/46766#M26639</link>
      <description>&lt;P&gt;I'm a student&amp;nbsp;using JMP for my first time, so apologies for any wrong terminology.&lt;BR /&gt;I'm using this formula to assign a code to different spending ranges for RFM analysis.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="If Formula.png" style="width: 282px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8213iE0D67BE109E478E6/image-size/large?v=v2&amp;amp;px=999" role="button" title="If Formula.png" alt="If Formula.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem I'm encountering is&amp;nbsp;with the top value 259.85. It sometimes returns the correct code "5" and other times returns a blank cell.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Example.png" style="width: 295px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8214iB8EA7F6D3F507EBC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Example.png" alt="Example.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Can anybody help me clear this up? Thanks for any input!&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 01:19:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-quot-If-quot-formula-sometimes-returns-blank-cells/m-p/46766#M26639</guid>
      <dc:creator>mrichie</dc:creator>
      <dc:date>2017-11-04T01:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using "If" formula sometimes returns blank cells</title>
      <link>https://community.jmp.com/t5/Discussions/Using-quot-If-quot-formula-sometimes-returns-blank-cells/m-p/46768#M26640</link>
      <description>&lt;P&gt;The value total_money could be between 259.84 and 259.85.&amp;nbsp; You might try removing the upper bound of the 'else if' conditions in the if statement and leaving an open 'else' condition.&amp;nbsp; Two other common problems that do not appear to apply here are missing data and the wrong type of data. Here is an example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="conditional.PNG" style="width: 237px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8215i1C363962047B8302/image-size/large?v=v2&amp;amp;px=999" role="button" title="conditional.PNG" alt="conditional.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 01:49:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-quot-If-quot-formula-sometimes-returns-blank-cells/m-p/46768#M26640</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2017-11-04T01:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using "If" formula sometimes returns blank cells</title>
      <link>https://community.jmp.com/t5/Discussions/Using-quot-If-quot-formula-sometimes-returns-blank-cells/m-p/46770#M26641</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;ih. Based on your input I reworked the formula to look like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="If Formula 2.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8216i32F2A3B5BC25A11A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="If Formula 2.png" alt="If Formula 2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if that's exactly what you intended, but it follows the spirit of your advice, at least, in removing room for values to hide between the upper bounds of one if statement and&amp;nbsp;the lower bounds of the next.&lt;BR /&gt;It does seem odd to me, however, because I don't believe this data goes beyond 2 decimal points, so I don't understand how anything could fall between .84 and .85.&lt;/P&gt;&lt;P&gt;Thanks so much for the help!&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 02:21:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-quot-If-quot-formula-sometimes-returns-blank-cells/m-p/46770#M26641</guid>
      <dc:creator>mrichie</dc:creator>
      <dc:date>2017-11-04T02:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using "If" formula sometimes returns blank cells</title>
      <link>https://community.jmp.com/t5/Discussions/Using-quot-If-quot-formula-sometimes-returns-blank-cells/m-p/46789#M26653</link>
      <description>&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Uncharted/If-Secrets/ba-p/39558" target="_blank"&gt;Here's&lt;/A&gt; a blog on &lt;STRONG&gt;if&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Discussions/floating-number-error-with-a-simple-substraction/m-p/35822#M21130" target="_blank"&gt;Here's&lt;/A&gt; a previous question about representing base-10 decimal numbers in binary floating point. The short answer is a number like .1 or .2 is represented in binary much like 1/3 is in base 10: an infinite repeating sequence of digits. It gets truncated at some point, and rounded, and&amp;nbsp;might be slightly large or slightly small. (&lt;EM&gt;slightly&lt;/EM&gt; is about 1e-15). In the same way that .333+.333 != .667, .1+.2 !=.3&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;.1+.2==.3
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;0 // &lt;EM&gt;why not? subtract them and see why they are different&lt;/EM&gt;...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;(.1 + .2) - .3
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;5.55111512312578e-17 // &lt;EM&gt;that's a really small difference&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;This is not specific to JMP; see the Excel comment in the second link above.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending how Total_money was calculated, the value&amp;nbsp;near 259.85 may be 259.8500..01 or 259.8499..99 (roughly) and you might want your if statement to split the pennies at the half-way point (untested code, approximately right):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// caution: counting pennies using floating point will be painful!
if( total_money &amp;gt; 259.845, "5", // 259.85 and above
total_money &amp;gt; 139.895, "4", // 139.90 and above
total_money &amp;gt; 89.845, "3", // 89.85 and above
...
"0") // none of the above&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The &lt;EM&gt;if&lt;/EM&gt; does each test in order and uses the first true answer. The final "0" answer has no test and is the &lt;EM&gt;else&lt;/EM&gt; clause of the if statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Nov 2017 23:31:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-quot-If-quot-formula-sometimes-returns-blank-cells/m-p/46789#M26653</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2017-11-05T23:31:59Z</dc:date>
    </item>
  </channel>
</rss>

