<?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: Onlinemap date difference and color return in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1211742#M47831</link>
    <description>&lt;P&gt;The biggest problem here is line 8, in which you have a return. This isn't the same as &lt;STRONG&gt;print()&lt;/STRONG&gt; in python; once you hit "return", the expression ends.&lt;/P&gt;&lt;P&gt;How is your popup configured, exactly? Having two strings in your &lt;STRONG&gt;return &lt;/STRONG&gt;statement isn't right, in line line 20, and your other returns in the conditional statements will just attempt to join the number to the hex code. I don't see how the hex code is actually being used.&lt;/P&gt;&lt;P&gt;If your popup used an Arcade object, you can use something like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var startDate = Date($feature["Received_date"])
var endDate = Date($feature["PI_DecisionDate1"])

var age = DateDiff(endDate, startDate, 'days')

var age_str = Iif(
    !IsEmpty(endDate),
    `Response time: ${Text(age)} Days`,
    'IN PROGRESS'
)

var age_color = When(
    age &amp;lt;= 30, "#2986cc",
    age &amp;gt; 30), "#d21c06",
    "#f9905d"
)

return { 
    type : 'text', 
    text : `&amp;lt;font color=${age_color}&amp;gt;${age_str}`
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Sep 2022 18:27:21 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2022-09-12T18:27:21Z</dc:date>
    <item>
      <title>Onlinemap date difference and color return</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1211724#M47829</link>
      <description>&lt;P&gt;I been trying to start this basic Arcade expression, well I thought it was basic. I want to display the difference between two date fields and if the number of days are less then 30 display the number of days in blue, if the number of days are over 30 days display the number of days in red. if there is no date in the "PI_DecisionDate1" then return "In Progress".&lt;/P&gt;&lt;P&gt;Here is what I have started, both fields are date fields&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// Write a script to return a value to show in the pop-up.
// For example, get the average of 4 fields:
// Average($feature.SalesQ1, $feature.SalesQ2, $feature.SalesQ3, $feature.SalesQ4)

var startDate = Date($feature["Received_date"])
var endDate = Date($feature["PI_DecisionDate1"])
var age = DateDiff(endDate, startDate, 'days');
return "response time" + " " +age + " " + "Days";

//Less than
IF(age &amp;lt;= 30){
    return age + "#2986cc"
}
//Greater than
IF (age &amp;gt;= 31){
    return age + "D21C06"
}
// else return
// else{
//  return "IN PROGRESS" "F9905D"   
//}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;result with the above, but I don't see the days populated when I click on the features on the map. Also, the formula doesn't see right from what I can tell.&lt;/P&gt;&lt;P&gt;Result Value&lt;/P&gt;&lt;TABLE width="701px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="70px"&gt;Result&lt;/TD&gt;&lt;TD width="631px"&gt;response time 43 Days&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="70px"&gt;Type&lt;/TD&gt;&lt;TD width="631px"&gt;String&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 12 Sep 2022 18:04:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1211724#M47829</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2022-09-12T18:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Onlinemap date difference and color return</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1211742#M47831</link>
      <description>&lt;P&gt;The biggest problem here is line 8, in which you have a return. This isn't the same as &lt;STRONG&gt;print()&lt;/STRONG&gt; in python; once you hit "return", the expression ends.&lt;/P&gt;&lt;P&gt;How is your popup configured, exactly? Having two strings in your &lt;STRONG&gt;return &lt;/STRONG&gt;statement isn't right, in line line 20, and your other returns in the conditional statements will just attempt to join the number to the hex code. I don't see how the hex code is actually being used.&lt;/P&gt;&lt;P&gt;If your popup used an Arcade object, you can use something like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var startDate = Date($feature["Received_date"])
var endDate = Date($feature["PI_DecisionDate1"])

var age = DateDiff(endDate, startDate, 'days')

var age_str = Iif(
    !IsEmpty(endDate),
    `Response time: ${Text(age)} Days`,
    'IN PROGRESS'
)

var age_color = When(
    age &amp;lt;= 30, "#2986cc",
    age &amp;gt; 30), "#d21c06",
    "#f9905d"
)

return { 
    type : 'text', 
    text : `&amp;lt;font color=${age_color}&amp;gt;${age_str}`
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 18:27:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1211742#M47831</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-09-12T18:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Onlinemap date difference and color return</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1211775#M47835</link>
      <description>&lt;P&gt;All I have configured on my popup is &lt;SPAN&gt;{expression/expr1}. Not sure how to set it up, I've been looking for some video or blogs but I haven't' found one that explains how to configure the pop with the arcade expression. I was trying to originally wanted to display this in a Dashboard, to get an average of all, but couldn't figure out how so I thought I would try this on the map.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I was able to get the popup to work with the following&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var startDate = Date($feature["Received_date"])
var endDate = Date($feature["PI_DecisionDate1"])
var age = DateDiff(endDate, startDate, 'days');
return "response time" + " " +age + " " + "Days";&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But just a simple response time "10" days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With yours&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var startDate = Date($feature["Received_date"])
var endDate = Date($feature["PI_DecisionDate1"])

var age = DateDiff(endDate, startDate, 'days')

var age_str = Iif(
    !IsEmpty(endDate),
    `Response time: ${Text(age)} Days`,
    'IN PROGRESS'
)

var age_color = When(
    age &amp;lt;= 30, "#2986cc",
    age &amp;gt; 30, "#d21c06",
    "#f9905d"
)

return { 
    type : 'text', 
    text : `&amp;lt;font color=${age_color}&amp;gt;${age_str}`
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the following when I hit the Test button.&lt;/P&gt;&lt;P&gt;Result Value&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Result&lt;/TD&gt;&lt;TD&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;A target="_blank"&gt;text&lt;/A&gt;&lt;/TD&gt;&lt;TD&gt;&amp;lt;font color=#2986cc&amp;gt;Response time: 22 Days&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;A target="_blank"&gt;type&lt;/A&gt;&lt;/TD&gt;&lt;TD&gt;text&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Type&lt;/TD&gt;&lt;TD&gt;Dictionary&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Map popup display.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[object Object]&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 19:43:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1211775#M47835</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2022-09-12T19:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Onlinemap date difference and color return</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1211803#M47838</link>
      <description>&lt;P&gt;I suppose I should have asked: is this in the Map Viewer or the Map Viewer Classic?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 21:06:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1211803#M47838</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-09-12T21:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: Onlinemap date difference and color return</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1211829#M47839</link>
      <description>&lt;P&gt;In Map View Classic.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 21:57:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1211829#M47839</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2022-09-12T21:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: Onlinemap date difference and color return</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1211834#M47840</link>
      <description>&lt;P&gt;Ah, okay. There's no way to do this with a single expression, then. You'll need one expression for the text, and a separate expression for the hex code.&lt;/P&gt;&lt;P&gt;Then set the popup to a custom text format display, switch the display to "view HTML source", and enter the text:&lt;/P&gt;&lt;PRE&gt;&amp;lt;font color={expression/expr1}&amp;gt;{expression/expr0}&amp;lt;/font&amp;gt;&lt;/PRE&gt;&lt;P&gt;That should do it.&lt;/P&gt;&lt;P&gt;Any particular reason to use the classic map viewer?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 22:06:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1211834#M47840</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-09-12T22:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Onlinemap date difference and color return</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1212121#M47857</link>
      <description>&lt;P&gt;I made some changes to my arcade expressions and was able to get to work like I wanted to with the color but the issue I am having now is that if the "days" are "0", what I have as return"IN PROGRESS" doesn't work/popup. how can I get to return ""IN PROGRESS" if the there is zero days?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expression 1&lt;/P&gt;&lt;P&gt;var startDate = Date($feature["Received_date"])&lt;BR /&gt;var endDate = Date($feature["PI_DecisionDate1"])&lt;BR /&gt;var age = DateDiff(endDate, startDate, 'days');&lt;BR /&gt;// return "Response time:" + " " + age + "days";&lt;/P&gt;&lt;P&gt;if (age &amp;gt;= 0){&lt;BR /&gt;return "Response time:" + " " + age + "days";&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;else if (age &amp;lt;= 0){&lt;BR /&gt;return "IN PROGRESS";&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expression 2&lt;/P&gt;&lt;P&gt;var days = Round(DateDiff($feature["PI_DecisionDate1"], $feature["Received_date"], 'days'),0);&lt;/P&gt;&lt;P&gt;var result = ""&lt;BR /&gt;if (days &amp;lt;= 31){&lt;BR /&gt;//Less than&lt;BR /&gt;result = "#0a75ad";&lt;BR /&gt;//Greater&lt;BR /&gt;} else if (days &amp;gt;= 31){&lt;BR /&gt;result = "#fe015a";&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;return result;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTML&lt;/P&gt;&lt;P&gt;&amp;lt;p style="color:{expression/expr2};"&amp;gt;&amp;lt;font size="4"&amp;gt;{expression/expr1}&amp;lt;/font&amp;gt;&amp;lt;/p&amp;gt;‍&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 18:46:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/onlinemap-date-difference-and-color-return/m-p/1212121#M47857</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2022-09-13T18:46:19Z</dc:date>
    </item>
  </channel>
</rss>

