<?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 Advanced formatting with a range of values in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/using-advanced-formatting-with-a-range-of-values/m-p/1181544#M6408</link>
    <description>&lt;P&gt;You can make the expression simpler. You don't need to check in line 2 whether the value is greater than 4 since that was already done in line 1.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var bcolor = When($datapoint["wave_height"] &amp;lt; 4, '#2e8540', 
            $datapoint["wave_height"] &amp;lt;= 6, '#fdb81e', 
            $datapoint["wave_height"] &amp;gt; 6, '#981b1e',
            '');&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;You could make it even simpler, but it may not be as intuitive&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var bcolor = When($datapoint["wave_height"] &amp;lt; 4, '#2e8540', 
            $datapoint["wave_height"] &amp;lt;= 6, '#fdb81e', 
            '#981b1e');&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jun 2022 17:11:25 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2022-06-09T17:11:25Z</dc:date>
    <item>
      <title>Using Advanced formatting with a range of values</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/using-advanced-formatting-with-a-range-of-values/m-p/1180465#M6398</link>
      <description>&lt;P&gt;I am using Advanced formatting in ArcGIS Dashboard, however, the data I am trying to display is not displaying in the correct color. Anything over 4 is yellow. How do I create status colors correctly for a range of values in advanced formatting?&lt;/P&gt;&lt;P&gt;var green = '#2e8540'&lt;BR /&gt;var yellow = '#fdb81e'&lt;BR /&gt;var red = '#981b1e'&lt;/P&gt;&lt;P&gt;if($datapoint["wave_height"] &amp;lt; 4) {&lt;BR /&gt;return {&lt;BR /&gt;textColor:'#ffffff',&lt;BR /&gt;backgroundColor: green,&lt;BR /&gt;topText: 'Wave Height',&lt;BR /&gt;topTextColor: '',&lt;BR /&gt;topTextOutlineColor: '',&lt;BR /&gt;topTextMaxSize: 'medium',&lt;BR /&gt;middleText: Text($datapoint["wave_height"], '#.# ft'),&lt;BR /&gt;middleTextColor: '',&lt;BR /&gt;middleTextOutlineColor: '',&lt;BR /&gt;middleTextMaxSize: 'medium',&lt;BR /&gt;//bottomText: '',&lt;BR /&gt;//bottomTextColor: '',&lt;BR /&gt;//bottomTextOutlineColor: '',&lt;BR /&gt;//bottomTextMaxSize: 'medium',&lt;BR /&gt;iconName:'icon1',&lt;BR /&gt;iconAlign:'left',&lt;BR /&gt;iconColor:'#ffffff',&lt;BR /&gt;iconOutlineColor:''&lt;BR /&gt;//noValue:false,&lt;BR /&gt;//attributes: {&lt;BR /&gt;// attribute1: '',&lt;BR /&gt;// attribute2: ''&lt;BR /&gt;// }&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;else if($datapoint["wave_height"] &amp;gt;= 4) {&lt;BR /&gt;return {&lt;BR /&gt;textColor:'#ffffff',&lt;BR /&gt;backgroundColor: yellow,&lt;BR /&gt;topText: 'Wave Height',&lt;BR /&gt;topTextColor: '',&lt;BR /&gt;topTextOutlineColor: '',&lt;BR /&gt;topTextMaxSize: 'medium',&lt;BR /&gt;middleText: Text($datapoint["wave_height"], '#.# ft'),&lt;BR /&gt;middleTextColor: '',&lt;BR /&gt;middleTextOutlineColor: '',&lt;BR /&gt;middleTextMaxSize: 'medium',&lt;BR /&gt;//bottomText: '',&lt;BR /&gt;//bottomTextColor: '',&lt;BR /&gt;//bottomTextOutlineColor: '',&lt;BR /&gt;//bottomTextMaxSize: 'medium',&lt;BR /&gt;iconName:'icon1',&lt;BR /&gt;iconAlign:'left',&lt;BR /&gt;iconColor:'#ffffff',&lt;BR /&gt;iconOutlineColor:''&lt;BR /&gt;//noValue:false,&lt;BR /&gt;//attributes: {&lt;BR /&gt;// attribute1: '',&lt;BR /&gt;// attribute2: ''&lt;BR /&gt;// }&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;else if($datapoint["wave_height"] &amp;lt; 6) {&lt;BR /&gt;return {&lt;BR /&gt;textColor:'#ffffff',&lt;BR /&gt;backgroundColor: yellow,&lt;BR /&gt;topText: 'Wave Height',&lt;BR /&gt;topTextColor: '',&lt;BR /&gt;topTextOutlineColor: '',&lt;BR /&gt;topTextMaxSize: 'medium',&lt;BR /&gt;middleText: Text($datapoint["wave_height"], '#.# ft'),&lt;BR /&gt;middleTextColor: '',&lt;BR /&gt;middleTextOutlineColor: '',&lt;BR /&gt;middleTextMaxSize: 'medium',&lt;BR /&gt;//bottomText: '',&lt;BR /&gt;//bottomTextColor: '',&lt;BR /&gt;//bottomTextOutlineColor: '',&lt;BR /&gt;//bottomTextMaxSize: 'medium',&lt;BR /&gt;iconName:'icon1',&lt;BR /&gt;iconAlign:'left',&lt;BR /&gt;iconColor:'#ffffff',&lt;BR /&gt;iconOutlineColor:''&lt;BR /&gt;//noValue:false,&lt;BR /&gt;//attributes: {&lt;BR /&gt;// attribute1: '',&lt;BR /&gt;// attribute2: ''&lt;BR /&gt;// }&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;else if($datapoint["wave_height"] &amp;gt;= 6) {&lt;BR /&gt;return {&lt;BR /&gt;textColor:'#ffffff',&lt;BR /&gt;backgroundColor: red,&lt;BR /&gt;topText: 'Wave Height',&lt;BR /&gt;topTextColor: '',&lt;BR /&gt;topTextOutlineColor: '',&lt;BR /&gt;topTextMaxSize: 'medium',&lt;BR /&gt;middleText: Text($datapoint["wave_height"], '#.# ft'),&lt;BR /&gt;middleTextColor: '',&lt;BR /&gt;middleTextOutlineColor: '',&lt;BR /&gt;middleTextMaxSize: 'medium',&lt;BR /&gt;//bottomText: '',&lt;BR /&gt;//bottomTextColor: '',&lt;BR /&gt;//bottomTextOutlineColor: '',&lt;BR /&gt;//bottomTextMaxSize: 'medium',&lt;BR /&gt;iconName:'icon1',&lt;BR /&gt;iconAlign:'left',&lt;BR /&gt;iconColor:'#ffffff',&lt;BR /&gt;iconOutlineColor:''&lt;BR /&gt;//noValue:false,&lt;BR /&gt;//attributes: {&lt;BR /&gt;// attribute1: '',&lt;BR /&gt;// attribute2: ''&lt;BR /&gt;// }&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;else if($datapoint["wave_height"] == 100) {&lt;BR /&gt;return {&lt;BR /&gt;textColor:'#ffffff',&lt;BR /&gt;backgroundColor: red,&lt;BR /&gt;topText: 'Wave Height',&lt;BR /&gt;topTextColor: '',&lt;BR /&gt;topTextOutlineColor: '',&lt;BR /&gt;topTextMaxSize: 'medium',&lt;BR /&gt;middleText: 'No data',&lt;BR /&gt;middleTextColor: '',&lt;BR /&gt;middleTextOutlineColor: '',&lt;BR /&gt;middleTextMaxSize: 'medium',&lt;BR /&gt;//bottomText: '',&lt;BR /&gt;//bottomTextColor: '',&lt;BR /&gt;//bottomTextOutlineColor: '',&lt;BR /&gt;//bottomTextMaxSize: 'medium',&lt;BR /&gt;iconName:'icon1',&lt;BR /&gt;iconAlign:'left',&lt;BR /&gt;iconColor:'#ffffff',&lt;BR /&gt;iconOutlineColor:''&lt;BR /&gt;//noValue:false,&lt;BR /&gt;//attributes: {&lt;BR /&gt;// attribute1: '',&lt;BR /&gt;// attribute2: ''&lt;BR /&gt;// }&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 23:43:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/using-advanced-formatting-with-a-range-of-values/m-p/1180465#M6398</guid>
      <dc:creator>jkeatonthompson</dc:creator>
      <dc:date>2022-06-06T23:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using Advanced formatting with a range of values</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/using-advanced-formatting-with-a-range-of-values/m-p/1180602#M6401</link>
      <description>&lt;P&gt;Anything greater than 4 is yellow because that is what your second 'section' states should happen. Once it evaluates as true it stops, so 5, 7, 100, etc are all over 4 and therefore true so it stops there and doesn't check to see if it belongs to another color bucket.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I understand your buckets correctly what you want is:&lt;/P&gt;&lt;P&gt;&amp;lt; 4 = green&lt;BR /&gt;&amp;gt;= 4 and &amp;lt;= 6 = yellow*&lt;BR /&gt;&amp;gt; 6 = red&lt;/P&gt;&lt;P&gt;*Technically 6 in your example is not assigned a color so I grouped it with the yellows.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You want your expression to match these buckets, so the yellow bucket should have a minimum and maximum value to constrain it. These values should not be included in the other buckets. Remember, any possibly value you may have should evaluate true only once.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also find it easier to have a single return statement that uses variables:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var bcolor = When($datapoint["wave_height"]  &amp;lt; 4, '#2e8540', 
            $datapoint["wave_height"]  &amp;gt;= 4 &amp;amp;&amp;amp; $datapoint["wave_height"]  &amp;lt;= 6, '#fdb81e', 
            $datapoint["wave_height"]  &amp;gt; 6, '#981b1e', '')


var mtext = When($datapoint["wave_height"]  == 100, '', Text($datapoint["wave_height"] , '#.# ft'))

return {
    //textColor:'',
    backgroundColor:bcolor,
    //topText: '',
    //topTextColor: '',
    //topTextOutlineColor: '',
    //topTextMaxSize: 'medium',
    middleText: mtext,
    middleTextColor: '',
    middleTextOutlineColor: '',
    middleTextMaxSize: 'large',
    //bottomText: '',
    //bottomTextColor: '',
    //bottomTextOutlineColor: '',
    //bottomTextMaxSize: 'medium',
    //iconName:'',
    //iconAlign:'left',
    //iconColor:'',
    //iconOutlineColor:'',
    //noValue:false,
    //attributes: {
      // attribute1: '',
      // attribute2: ''
    // }
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 14:14:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/using-advanced-formatting-with-a-range-of-values/m-p/1180602#M6401</guid>
      <dc:creator>JenniferAcunto</dc:creator>
      <dc:date>2022-06-07T14:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using Advanced formatting with a range of values</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/using-advanced-formatting-with-a-range-of-values/m-p/1180818#M6403</link>
      <description>&lt;P&gt;Thanks allot Jennifer! That was extremely helpful and so far all of my indicators have worked successfully.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 21:46:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/using-advanced-formatting-with-a-range-of-values/m-p/1180818#M6403</guid>
      <dc:creator>jkeatonthompson</dc:creator>
      <dc:date>2022-06-07T21:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using Advanced formatting with a range of values</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/using-advanced-formatting-with-a-range-of-values/m-p/1181544#M6408</link>
      <description>&lt;P&gt;You can make the expression simpler. You don't need to check in line 2 whether the value is greater than 4 since that was already done in line 1.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var bcolor = When($datapoint["wave_height"] &amp;lt; 4, '#2e8540', 
            $datapoint["wave_height"] &amp;lt;= 6, '#fdb81e', 
            $datapoint["wave_height"] &amp;gt; 6, '#981b1e',
            '');&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;You could make it even simpler, but it may not be as intuitive&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var bcolor = When($datapoint["wave_height"] &amp;lt; 4, '#2e8540', 
            $datapoint["wave_height"] &amp;lt;= 6, '#fdb81e', 
            '#981b1e');&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 17:11:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/using-advanced-formatting-with-a-range-of-values/m-p/1181544#M6408</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2022-06-09T17:11:25Z</dc:date>
    </item>
  </channel>
</rss>

