{"id":1946822,"date":"2023-06-06T10:01:58","date_gmt":"2023-06-06T17:01:58","guid":{"rendered":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=1946822"},"modified":"2024-10-31T23:57:36","modified_gmt":"2024-11-01T06:57:36","slug":"five-under-appreciated-arcade-functions","status":"publish","type":"blog","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions","title":{"rendered":"Five under-appreciated Arcade functions"},"author":6561,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_acf_changed":false,"_searchwp_excluded":""},"categories":[777102,738191,22941],"tags":[32551,30111,212872],"industry":[],"product":[761642,36831,36551,36601],"class_list":["post-1946822","blog","type-blog","status-publish","format-standard","hentry","category-arcade","category-developers","category-mapping","tag-arcade","tag-data-visualization","tag-popups","product-platform","product-js-api-arcgis","product-arcgis-online","product-developers"],"acf":{"short_description":"These Arcade functions don't get enough love.","flexible_content":[{"acf_fc_layout":"content","content":"<p><a href=\"https:\/\/developers.arcgis.com\/arcade\/\">Arcade<\/a> is an expression language that allows you to create <a href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/part-1-introducing-arcade-pop-up-content-elements\/\">custom content in popups<\/a>, <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/sample-code\/labels-multiline\/\">format labels<\/a>, create <a href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/create-a-diversity-index-with-arcade\/\">new data values for visualizations<\/a>, and <a href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-pro\/data-management\/originalfeature-new-attribute-rules-arcade-global\/\">enforce rules<\/a> in various workflows. <a href=\"https:\/\/www.esri.com\/arcgis-blog\/?s=#&amp;tag=arcade\">A lot has already been written about Arcade<\/a>, what it is, and why you would use it.<\/p>\n<p>I\u2019ve seen a lot of Arcade expressions from the Esri user community. Over the years, I&#8217;ve noticed common patterns that can be simplified by using <a href=\"https:\/\/developers.arcgis.com\/arcade\/function-reference\/\">out-of-the box Arcade functions<\/a>. Most of the time, expression authors aren&#8217;t aware of the functionality they&#8217;re missing out on. In this post, I&#8217;ll demonstrate five under-appreciated Arcade functions and how they can improve your expressions.<\/p>\n<ol>\n<li><a href=\"#iif\">iif<\/a><\/li>\n<li><a href=\"#text\">Text<\/a><\/li>\n<li><a href=\"#decode\">Decode<\/a><\/li>\n<li><a href=\"#defaultvalue\">DefaultValue<\/a><\/li>\n<li><a href=\"#number\">Number<\/a><\/li>\n<\/ol>\n"},{"acf_fc_layout":"content","content":"<p><a name=\"iif\"><\/a><\/p>\n<h2>1. iif<\/h2>\n<p>The <a href=\"https:\/\/developers.arcgis.com\/arcade\/function-reference\/logical_functions\/#iif\">iif<\/a> function returns a value if a conditional expression evaluates to <code>true<\/code>, and returns an alternate value if the condition evaluates to <code>false<\/code>. This is particularly useful in simple scenarios such as writing an expression to indicate when a value has reached a threshold.<\/p>\n<p>Commonly, expressions use <a href=\"https:\/\/developers.arcgis.com\/arcade\/guide\/logic\/\">if-else<\/a> blocks to conditionally return values.<\/p>\n<pre><code><span style=\"color: #d73a49;\">var<\/span> category = <span style=\"color: #032f62;\">\"\"<\/span>;\r\n\r\n<span style=\"color: #d73a49;\">if<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.value &gt; <span style=\"color: #005cc5;\">100<\/span>){\r\n    category = <span style=\"color: #032f62;\">\"high\"<\/span>;\r\n} <span style=\"color: #d73a49;\">else<\/span> {\r\n    category = <span style=\"color: #032f62;\">\"low\"<\/span>;\r\n}\r\n<span style=\"color: #d73a49;\">return<\/span> category;\r\n<\/code><\/pre>\n<p>However, the <code>iif<\/code> function simplifies this into two lines without the need for multiple returns or variable assignments&#8230;<\/p>\n<pre><code><span style=\"color: #6a737d;\">\/\/ if the value is more than 100, return \"high\"<\/span>\r\n<span style=\"color: #6a737d;\">\/\/ otherwise, return \"low\"<\/span>\r\n<span style=\"color: #d73a49;\">var<\/span> category = <span style=\"color: #e36209;\">IIF<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.value &gt; <span style=\"color: #005cc5;\">100<\/span>, <span style=\"color: #032f62;\">\"high\"<\/span>, <span style=\"color: #032f62;\">\"low\"<\/span>);\r\n<span style=\"color: #d73a49;\">return<\/span> category;\r\n<\/code><\/pre>\n<p>&#8230;or to one line (thanks to <a href=\"https:\/\/developers.arcgis.com\/arcade\/guide\/return\/#implicit-returns\">implicit returns<\/a>).<\/p>\n<pre><code><span style=\"color: #e36209;\">IIF<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.value &gt; <span style=\"color: #005cc5;\">100<\/span>, <span style=\"color: #032f62;\">\"high\"<\/span>, <span style=\"color: #032f62;\">\"low\"<\/span>);\r\n<\/code><\/pre>\n<p>There is nothing wrong with using an <code>if-else<\/code> block to return conditional content. In fact, you <em>should<\/em> use <code>if<\/code> statements if you must evaluate other statements that follow the same conditions, including assigning values to variables. In the following example, the <code>iif<\/code> function is not appropriate because multiple variable assignments take place if the condition is true.<\/p>\n<pre><code><span style=\"color: #d73a49;\">if<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.value &gt; <span style=\"color: #005cc5;\">100<\/span>){\r\n  percentAbove = <span style=\"color: #e36209;\">$feature<\/span>.value - <span style=\"color: #005cc5;\">100<\/span>;\r\n  category = <span style=\"color: #032f62;\">\"high\"<\/span>;\r\n} <span style=\"color: #d73a49;\">else<\/span> {\r\n  category = <span style=\"color: #032f62;\">\"low\"<\/span>;\r\n}\r\n<span style=\"color: #d73a49;\">return<\/span> <span style=\"color: #032f62;\">`<span style=\"color: #24292e;\">${category}<\/span> (<span style=\"color: #24292e;\">${percentAbove}<\/span>%)`<\/span>;\r\n<\/code><\/pre>\n<p>However, when all you need to do is return a value based on a simple condition, <code>iif<\/code> will condense and simplify your expression.<\/p>\n"},{"acf_fc_layout":"content","content":"<p><a name=\"text\"><\/a><\/p>\n<h2>2. Text<\/h2>\n<p>The <a href=\"https:\/\/developers.arcgis.com\/arcade\/function-reference\/text_functions\/#text\">Text<\/a> function converts a value of any Arcade <a href=\"https:\/\/developers.arcgis.com\/arcade\/guide\/types\/\">data type<\/a> to an equivalent Text value. Many find this function useful when formatting dates, but I\u2019ve seen a lot of expressions that implement extra logic for formatting numbers that could be avoided simply by leveraging <code>Text<\/code>.<\/p>\n<p>This is especially true when it comes to rounding. You may ask: <em>why should I use <code>Text<\/code> for number rounding when Arcade already has a <a href=\"https:\/\/developers.arcgis.com\/arcade\/function-reference\/math_functions\/#round\">Round<\/a> function?<\/em> For example, this pattern is very common:<\/p>\n<pre><code><span style=\"color: #e36209;\">Round<\/span>((<span style=\"color: #e36209;\">$feature<\/span>.diplomas\/<span style=\"color: #e36209;\">$feature<\/span>.AdultPopulation) * <span style=\"color: #005cc5;\">100<\/span>, <span style=\"color: #005cc5;\">1<\/span>) + \u201c%\u201d;\r\n<span style=\"color: #6a737d;\">\/\/ returns \"37.8%\";<\/span>\r\n<\/code><\/pre>\n<p>However, <code>Text<\/code> provides you with a % option so you don&#8217;t have to do the math of converting a decimal number (0-1) to a percentage.<\/p>\n<pre><code><span style=\"color: #e36209;\">Text<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.diplomas\/<span style=\"color: #e36209;\">$feature<\/span>.AdultPopulation, <span style=\"color: #032f62;\">\"#.#%\"<\/span>);\r\n<span style=\"color: #6a737d;\">\/\/ returns \"37.8%\";<\/span>\r\n<\/code><\/pre>\n<p>But does <code>Text<\/code> really make your expression better in this case? Yes! The two approaches are distinct because <code>Round<\/code> returns a number, and <code>Text<\/code> returns a text value. Here&#8217;s why this distinction is significant:<\/p>\n<p><strong><code>Round<\/code> changes the precision of the numbers<\/strong> you use for calculations within an expression <em>without actually formatting<\/em> the value. <strong><code>Text<\/code> allows you to format a number based on a formatting pattern.<\/strong> While <code>Text<\/code> helps with rounding numbers, it also allows you to specify separators for large numbers. In short, <code>Round<\/code> may round your decimal numbers; however, <code>Text<\/code> will round and add digit separators to large numbers.<\/p>\n<p>Despite all that, the biggest benefit to using <code>Text<\/code> is <strong>the formatting defined in <code>Text<\/code> also conforms to the locale of the app in which the expression executes.<\/strong> <code>Round<\/code> does not give you that benefit.<\/p>\n<p>Check out the following examples and note the differences. Text always returns a cleaner and more correct result.<\/p>\n<pre><code><span style=\"color: #d73a49;\">var<\/span> v = <span style=\"color: #005cc5;\">2891.378268263982736<\/span>;\r\n<span style=\"color: #e36209;\">Round<\/span>(v, <span style=\"color: #005cc5;\">2<\/span>);\r\n<span style=\"color: #6a737d;\">\/\/ returns 2891.38 in English, no digit separator<\/span>\r\n<span style=\"color: #6a737d;\">\/\/ returns 2891.38 in Spanish, no digit separator (incorrect format)<\/span>\r\n\r\n<span style=\"color: #e36209;\">Text<\/span>(v, <span style=\"color: #032f62;\">\"#,###.##\"<\/span>);\r\n<span style=\"color: #6a737d;\">\/\/ returns \"2,891.38\" in English, with a digit separator<\/span>\r\n<span style=\"color: #6a737d;\">\/\/ returns \"2.891,38\" in Spanish (correct format)<\/span>\r\n<\/code><\/pre>\n"},{"acf_fc_layout":"sidebar","content":"<p><strong>If Text is preferred for number formatting, when should I use Round?<\/strong><\/p>\n<p>In many cases, dividing two numbers results in a number with many decimal places. The resulting level of precision is often too high or not required by the end user. <code>Round<\/code> helps you control precision within your formula. You should also use <code>Round<\/code> when you need to return the result as a number (like in a field calculation or a renderer value) or continue using it as input for another Arcade function when less precision is required.<\/p>\n","image_reference":false,"layout":"standard","image_reference_figure":"","snippet":"","spotlight_name":"","section_title":"","position":"Center","spotlight_image":false},{"acf_fc_layout":"content","content":"<p>I\u2019ve also seen people use <code>iif<\/code> to format values above and below zero, like this:<\/p>\n<pre><code><span style=\"color: #d73a49;\">var<\/span> previous = <span style=\"color: #e36209;\">$feature<\/span>.pop2020;  <span style=\"color: #6a737d;\">\/\/ 3020<\/span>\r\n<span style=\"color: #d73a49;\">var<\/span> current = <span style=\"color: #e36209;\">$feature<\/span>.pop2023;   <span style=\"color: #6a737d;\">\/\/ 3333<\/span>\r\n<span style=\"color: #d73a49;\">var<\/span> change = (current - previous) \/ previous;\r\n\r\n<span style=\"color: #e36209;\">IIF<\/span>(change &gt; <span style=\"color: #005cc5;\">0<\/span>, <span style=\"color: #032f62;\">\"\u2b06\"<\/span>, <span style=\"color: #032f62;\">\"\u2b07\"<\/span>) + <span style=\"color: #e36209;\">Round<\/span>(change*<span style=\"color: #005cc5;\">100<\/span>, <span style=\"color: #005cc5;\">2<\/span>) + <span style=\"color: #032f62;\">\"%\"<\/span>;\r\n<span style=\"color: #6a737d;\">\/\/ returns \"\u2b0610.4%\" in English<\/span>\r\n<span style=\"color: #6a737d;\">\/\/ returns \"\u2b0610.4%\" in Spanish (incorrect)<\/span>\r\n<\/code><\/pre>\n<p>As noted in the potential results, this will yield bad formatting in many non-English locales. The format pattern parameter of <code>Text<\/code> actually provides an option that allows you to specify a different format for positive or negative values. Simply separate the two patterns with a semi-colon and Arcade will do the work for you. There is no need to use <code>iif<\/code> at all.<\/p>\n<pre><code><span style=\"color: #d73a49;\">var<\/span> previous = <span style=\"color: #e36209;\">$feature<\/span>.pop2020;  <span style=\"color: #6a737d;\">\/\/ 3020<\/span>\r\n<span style=\"color: #d73a49;\">var<\/span> current = <span style=\"color: #e36209;\">$feature<\/span>.pop2023;   <span style=\"color: #6a737d;\">\/\/ 3333<\/span>\r\n<span style=\"color: #d73a49;\">var<\/span> change = (current - previous) \/ previous;\r\n\r\n<span style=\"color: #e36209;\">Text<\/span>(change, <span style=\"color: #032f62;\">\"\u2b06#.#%;\u2b07#.#%\"<\/span>);\r\n<span style=\"color: #6a737d;\">\/\/ returns \"\u2b0610.4%\" in English<\/span>\r\n<span style=\"color: #6a737d;\">\/\/ returns \"\u2b0610,4%\" in Spanish (correct)<\/span>\r\n<\/code><\/pre>\n<p>The following images demonstrate how using <code>Round<\/code> will result in popup values looking incorrect depending on the locale.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":1948772,"id":1948772,"title":"Screenshot 2023-05-31 at 3.49.43 PM","filename":"Screenshot-2023-05-31-at-3.49.43-PM.png","filesize":34077,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.43-PM.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions\/screenshot-2023-05-31-at-3-49-43-pm","alt":"Popup content \"formatted\" using the Round function. Round only changes the precision of floating point values, which are then cast to text as is without any real formatting taking place.","author":"6561","description":"","caption":"Popup content \"formatted\" using the Round function. Round only changes the precision of floating point values, which are then cast to text as is without any real formatting taking place. This will always be the result no matter the locale of the browser.","name":"screenshot-2023-05-31-at-3-49-43-pm","status":"inherit","uploaded_to":1946822,"date":"2023-06-01 23:35:23","modified":"2023-06-02 00:46:22","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":446,"height":394,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.43-PM-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.43-PM.png","medium-width":295,"medium-height":261,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.43-PM.png","medium_large-width":446,"medium_large-height":394,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.43-PM.png","large-width":446,"large-height":394,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.43-PM.png","1536x1536-width":446,"1536x1536-height":394,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.43-PM.png","2048x2048-width":446,"2048x2048-height":394,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.43-PM.png","card_image-width":446,"card_image-height":394,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.43-PM.png","wide_image-width":446,"wide_image-height":394}},"image_position":"center","orientation":"horizontal","hyperlink":""},{"acf_fc_layout":"image","image":{"ID":1948782,"id":1948782,"title":"Screenshot 2023-05-31 at 3.52.35 PM","filename":"Screenshot-2023-05-31-at-3.52.35-PM.png","filesize":34257,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.52.35-PM.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions\/screenshot-2023-05-31-at-3-52-35-pm","alt":"Popup content formatted using the Text function and displayed in an English browser. When Text is used to format numbers, digit separators may be used. The formatting also conforms to the locale of the browser.","author":"6561","description":"","caption":"Popup content formatted using the Text function and displayed in an English browser. When Text is used to format numbers, digit separators may be used. The formatting also conforms to the locale of the browser.","name":"screenshot-2023-05-31-at-3-52-35-pm","status":"inherit","uploaded_to":1946822,"date":"2023-06-01 23:35:26","modified":"2023-06-01 23:39:02","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":391,"height":407,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.52.35-PM-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.52.35-PM.png","medium-width":251,"medium-height":261,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.52.35-PM.png","medium_large-width":391,"medium_large-height":407,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.52.35-PM.png","large-width":391,"large-height":407,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.52.35-PM.png","1536x1536-width":391,"1536x1536-height":407,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.52.35-PM.png","2048x2048-width":391,"2048x2048-height":407,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.52.35-PM.png","card_image-width":391,"card_image-height":407,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.52.35-PM.png","wide_image-width":391,"wide_image-height":407}},"image_position":"center","orientation":"horizontal","hyperlink":""},{"acf_fc_layout":"image","image":{"ID":1948762,"id":1948762,"title":"Screenshot 2023-05-31 at 3.49.32 PM","filename":"Screenshot-2023-05-31-at-3.49.32-PM.png","filesize":34337,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.32-PM.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions\/screenshot-2023-05-31-at-3-49-32-pm","alt":"Popup content formatted using the Text function and displayed in a Spanish browser. When Text is used to format numbers, digit separators may be used. The formatting also conforms to the locale of the browser.","author":"6561","description":"","caption":"Popup content formatted using the Text function and displayed in a Spanish browser. When Text is used to format numbers, digit separators may be used. The formatting also conforms to the locale of the browser.","name":"screenshot-2023-05-31-at-3-49-32-pm","status":"inherit","uploaded_to":1946822,"date":"2023-06-01 23:35:19","modified":"2023-06-01 23:39:22","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":447,"height":403,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.32-PM-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.32-PM.png","medium-width":289,"medium-height":261,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.32-PM.png","medium_large-width":447,"medium_large-height":403,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.32-PM.png","large-width":447,"large-height":403,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.32-PM.png","1536x1536-width":447,"1536x1536-height":403,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.32-PM.png","2048x2048-width":447,"2048x2048-height":403,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.32-PM.png","card_image-width":447,"card_image-height":403,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-05-31-at-3.49.32-PM.png","wide_image-width":447,"wide_image-height":403}},"image_position":"center","orientation":"horizontal","hyperlink":""},{"acf_fc_layout":"content","content":"<p><a name=\"decode\"><\/a><\/p>\n<h2>3. Decode<\/h2>\n<p><a href=\"https:\/\/developers.arcgis.com\/arcade\/function-reference\/logical_functions\/#decode\">Decode<\/a> finds a match for a coded value from a set of codes and returns an equivalent description of the matching code. This function can be used to evaluate <em>any expression<\/em> to a value and compare the result to a list of expected values and return a matching description, category, or other value.<\/p>\n<p>For example, the <code>TechCode<\/code> attribute in the following example is a coded value. I commonly see users return the description of the code using a sequence of <code>if<\/code> statements, like this:<\/p>\n<pre><code><span style=\"color: #d73a49;\">if<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.TechCode == <span style=\"color: #005cc5;\">30<\/span>){\r\n  <span style=\"color: #d73a49;\">return<\/span> <span style=\"color: #032f62;\">\"Copper Wireline\"<\/span>;\r\n}\r\n<span style=\"color: #d73a49;\">if<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.TechCode == <span style=\"color: #005cc5;\">40<\/span>){\r\n  <span style=\"color: #d73a49;\">return<\/span> <span style=\"color: #032f62;\">\"Cable Modem\"<\/span>;\r\n}\r\n<span style=\"color: #d73a49;\">if<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.TechCode == <span style=\"color: #005cc5;\">50<\/span>){\r\n  <span style=\"color: #d73a49;\">return<\/span> <span style=\"color: #032f62;\">\"Fiber\"<\/span>;\r\n}\r\n<span style=\"color: #d73a49;\">if<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.TechCode == <span style=\"color: #005cc5;\">60<\/span>){\r\n  <span style=\"color: #d73a49;\">return<\/span> <span style=\"color: #032f62;\">\"Satellite\"<\/span>;\r\n}\r\n<span style=\"color: #d73a49;\">if<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.TechCode == <span style=\"color: #005cc5;\">70<\/span>){\r\n  <span style=\"color: #d73a49;\">return<\/span> <span style=\"color: #032f62;\">\"Terrestrial Fixed Wireless\"<\/span>;\r\n}\r\n<span style=\"color: #d73a49;\">if<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.TechCode == <span style=\"color: #005cc5;\">90<\/span>){\r\n  <span style=\"color: #d73a49;\">return<\/span> <span style=\"color: #032f62;\">\"Electric Power Line\"<\/span>;\r\n}\r\n<\/code><\/pre>\n<p>Of course, this is valid syntax and returns a correct result. You could alternatively condense this expression using the <a href=\"https:\/\/developers.arcgis.com\/arcade\/function-reference\/logical_functions\/#when\">When<\/a> function:<\/p>\n<pre><code><span style=\"color: #e36209;\">When<\/span>(\r\n  <span style=\"color: #e36209;\">$feature<\/span>.TechCode == <span style=\"color: #005cc5;\">30<\/span>, <span style=\"color: #032f62;\">\"Copper Wireline\"<\/span>,\r\n  <span style=\"color: #e36209;\">$feature<\/span>.TechCode == <span style=\"color: #005cc5;\">40<\/span>, <span style=\"color: #032f62;\">\"Cable Modem\"<\/span>,\r\n  <span style=\"color: #e36209;\">$feature<\/span>.TechCode == <span style=\"color: #005cc5;\">50<\/span>, <span style=\"color: #032f62;\">\"Fiber\"<\/span>,\r\n  <span style=\"color: #e36209;\">$feature<\/span>.TechCode == <span style=\"color: #005cc5;\">60<\/span>, <span style=\"color: #032f62;\">\"Satellite\"<\/span>,\r\n  <span style=\"color: #e36209;\">$feature<\/span>.TechCode == <span style=\"color: #005cc5;\">70<\/span>, <span style=\"color: #032f62;\">\"Terrestrial Fixed Wireless\"<\/span>,\r\n  <span style=\"color: #e36209;\">$feature<\/span>.TechCode == <span style=\"color: #005cc5;\">90<\/span>, <span style=\"color: #032f62;\">\"Electric Power Line\"<\/span>,\r\n  <span style=\"color: #032f62;\">\"Other\"<\/span>\r\n);\r\n<\/code><\/pre>\n<p>This is also valid and returns a correct result. However, <strong>because the code comes from a single field<\/strong>, you can simply use <code>Decode<\/code> to return the description:<\/p>\n<pre><code><span style=\"color: #e36209;\">Decode<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.TechCode,\r\n  <span style=\"color: #005cc5;\">30<\/span>, <span style=\"color: #032f62;\">\"Copper Wireline\"<\/span>,\r\n  <span style=\"color: #005cc5;\">40<\/span>, <span style=\"color: #032f62;\">\"Cable Modem\"<\/span>,\r\n  <span style=\"color: #005cc5;\">50<\/span>, <span style=\"color: #032f62;\">\"Fiber\"<\/span>,\r\n  <span style=\"color: #005cc5;\">60<\/span>, <span style=\"color: #032f62;\">\"Satellite\"<\/span>,\r\n  <span style=\"color: #005cc5;\">70<\/span>, <span style=\"color: #032f62;\">\"Terrestrial Fixed Wireless\"<\/span>,\r\n  <span style=\"color: #005cc5;\">90<\/span>, <span style=\"color: #032f62;\">\"Electric Power Line\"<\/span>,\r\n  <span style=\"color: #032f62;\">\"Other\"<\/span>\r\n);\r\n<\/code><\/pre>\n<p>This is more compact, and (in my view) easier to read. <code>Decode<\/code> is preferred for <strong>evaluating a single expression<\/strong> and comparing the result to a list of known values. <code>When<\/code> is preferred for <strong>evaluating multiple expressions<\/strong> in a prioritized sequence, and returning a value once one of the statements is true.<\/p>\n<p><code>Decode<\/code> can also be used in clever ways such as comparing multiple numeric attributes from competing categories and returning the alias or description of the field <a href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/creating-a-predominance-visualization-with-arcade\/\">to visualize predominance<\/a>.<\/p>\n<p>For example, in an election dataset, you may have columns that represent the total count of votes for individual candidates, but no column that indicates the winner (because one hasn\u2019t been declared yet). You can use <code>Decode<\/code> to return the current leader in an election as results update:<\/p>\n<pre><code><span style=\"color: #d73a49;\">var<\/span> votesPerParty = [\r\n  <span style=\"color: #e36209;\">$feature<\/span>.Republican,\r\n  <span style=\"color: #e36209;\">$feature<\/span>.Democrat,\r\n  <span style=\"color: #e36209;\">$feature<\/span>.Green,\r\n  <span style=\"color: #e36209;\">$feature<\/span>.Libertarian,\r\n  <span style=\"color: #e36209;\">$feature<\/span>.Independent,\r\n];\r\n\r\n<span style=\"color: #6a737d;\">\/\/ Finds the largest number,<\/span>\r\n<span style=\"color: #6a737d;\">\/\/ matches it with the field it originates from<\/span>\r\n<span style=\"color: #6a737d;\">\/\/ and returns the alias of the field indicating the current leader<\/span>\r\n<span style=\"color: #d73a49;\">var<\/span> leader = <span style=\"color: #e36209;\">Decode<\/span>(<span style=\"color: #e36209;\">Max<\/span>(votesPerParty),\r\n  <span style=\"color: #e36209;\">$feature<\/span>.Republican, <span style=\"color: #032f62;\">\"Republican\"<\/span>,\r\n  <span style=\"color: #e36209;\">$feature<\/span>.Democrat, <span style=\"color: #032f62;\">\"Democrat\"<\/span>,\r\n  <span style=\"color: #e36209;\">$feature<\/span>.Green, <span style=\"color: #032f62;\">\"Green\"<\/span>,\r\n  <span style=\"color: #e36209;\">$feature<\/span>.Libertarian, <span style=\"color: #032f62;\">\"Libertarian\"<\/span>,\r\n  <span style=\"color: #e36209;\">$feature<\/span>.Independent, <span style=\"color: #032f62;\">\"Independent\"<\/span>,\r\n  <span style=\"color: #032f62;\">\"Other\"<\/span>\r\n);\r\n\r\n<span style=\"color: #d73a49;\">return<\/span> leader;\r\n<\/code><\/pre>\n"},{"acf_fc_layout":"content","content":"<p><a name=\"defaultvalue\"><\/a><\/p>\n<h2>4. DefaultValue<\/h2>\n<p><a href=\"https:\/\/developers.arcgis.com\/arcade\/function-reference\/logical_functions\/#defaultvalue\">DefaultValue<\/a> returns a value if an empty value (<code>null<\/code> or <code>''<\/code>) is detected. Users commonly want to display default text in case a value does not exist. Many people use a combination of <code>iif<\/code> and <a href=\"https:\/\/developers.arcgis.com\/arcade\/function-reference\/logical_functions\/#isempty\">IsEmpty<\/a> to account for empty values.<\/p>\n<pre><code><span style=\"color: #6a737d;\">\/\/ returns a default value of 0 if the data field is empty<\/span>\r\n<span style=\"color: #e36209;\">IIF<\/span>(!<span style=\"color: #e36209;\">IsEmpty<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.fieldName), <span style=\"color: #e36209;\">$feature<\/span>.fieldName, <span style=\"color: #005cc5;\">0<\/span>);\r\n<\/code><\/pre>\n<p>This works, but the <code>DefaultValue<\/code> function does all the lifting for you. All you have to do is specify which value you want to check, and the default value to return if it is empty.<\/p>\n<p>The equivalent to the previous expression is easier to read:<\/p>\n<pre><code><span style=\"color: #6a737d;\">\/\/ returns a default value of 0 if the data field is empty<\/span>\r\n<span style=\"color: #e36209;\">DefaultValue<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.fieldName, <span style=\"color: #005cc5;\">0<\/span>);\r\n<\/code><\/pre>\n<p>In popups, it can be helpful to display a message that no data is available so the user knows the data is collected in the layer, but isn&#8217;t available for the selected feature.<\/p>\n<pre><code><span style=\"color: #e36209;\">DefaultValue<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.status, <span style=\"color: #032f62;\">\"No data available\"<\/span>);\r\n<span style=\"color: #6a737d;\">\/\/ returns \"No data available\" if the status field is not populated<\/span>\r\n<\/code><\/pre>\n<p>I recently came across the following expression that could have been cut in half, had the expression author used <code>DefaultValue<\/code>. Note how the return value in the if and the else are nearly identical. The only difference is displaying the value of one attribute or another if the first is empty.<\/p>\n<pre><code><span style=\"color: #d73a49;\">var<\/span> percentageValue = <span style=\"color: #e36209;\">Round<\/span>((<span style=\"color: #e36209;\">$feature<\/span>.RecreationalVisits_int\/<span style=\"color: #e36209;\">$feature<\/span>.TotalRecreationVisits)*<span style=\"color: #005cc5;\">100<\/span>, <span style=\"color: #005cc5;\">2<\/span>) + <span style=\"color: #032f62;\">\"%\"<\/span>;\r\n<span style=\"color: #d73a49;\">var<\/span> unitType = <span style=\"color: #e36209;\">Lower<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.UNIT_TYPE);\r\n<span style=\"color: #d73a49;\">var<\/span> parkName = <span style=\"color: #e36209;\">$feature<\/span>.PARKNAME;\r\n\r\n<span style=\"color: #d73a49;\">if<\/span>(<span style=\"color: #e36209;\">IsEmpty<\/span>(parkName)){\r\n  <span style=\"color: #d73a49;\">return<\/span> {\r\n    <span style=\"color: #005cc5;\">text<\/span>: <span style=\"color: #032f62;\">\"{UNIT_NAME} is a \"<\/span> + unitType + <span style=\"color: #032f62;\">\" that had &lt;b&gt;\"<\/span> +\r\n    <span style=\"color: #032f62;\">\"{RecreationalVisits_int}&lt;\/b&gt; recreational visitors in 2022. \"<\/span> +\r\n    <span style=\"color: #032f62;\">\"This accounts for &lt;b&gt;\"<\/span> + percentageValue + <span style=\"color: #032f62;\">\"&lt;\/b&gt; of visits \"<\/span> +\r\n    <span style=\"color: #032f62;\">\"to all national parks in 2022.\"<\/span>\r\n  }\r\n} <span style=\"color: #d73a49;\">else<\/span> {\r\n  <span style=\"color: #d73a49;\">return<\/span> {\r\n    <span style=\"color: #005cc5;\">text<\/span>: <span style=\"color: #032f62;\">\"{PARKNAME} is a \"<\/span> + unitType + <span style=\"color: #032f62;\">\" that had &lt;b&gt;\"<\/span> +\r\n    <span style=\"color: #032f62;\">\"{RecreationalVisits_int}&lt;\/b&gt; recreational visitors in 2022. \"<\/span> +\r\n    <span style=\"color: #032f62;\">\"This accounts for &lt;b&gt;\"<\/span> + percentageValue + <span style=\"color: #032f62;\">\"&lt;\/b&gt; of visits \"<\/span> +\r\n    <span style=\"color: #032f62;\">\"to all national parks in 2022.\"<\/span>\r\n  }\r\n}\r\n<\/code><\/pre>\n<p>This is the updated expression leveraging <code>DefaultValue<\/code> for the <code>parkName<\/code> variable, which results in less text duplication in the expression. I also use <code>Text<\/code> to clean up the number formatting and make the values locale aware.<\/p>\n<pre><code><span style=\"color: #d73a49;\">var<\/span> percentageValue = <span style=\"color: #e36209;\">Text<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.RecreationalVisits_int\/<span style=\"color: #e36209;\">$feature<\/span>.TotalRecreationVisits, <span style=\"color: #032f62;\">\"#.##%\"<\/span>);\r\n<span style=\"color: #d73a49;\">var<\/span> unitType = <span style=\"color: #e36209;\">Lower<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.UNIT_TYPE);\r\n<span style=\"color: #d73a49;\">var<\/span> parkName = <span style=\"color: #e36209;\">DefaultValue<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.PARKNAME, <span style=\"color: #e36209;\">$feature<\/span>.UNIT_NAME);\r\n\r\n<span style=\"color: #d73a49;\">return<\/span> {\r\n  <span style=\"color: #005cc5;\">text<\/span> : parkName + <span style=\"color: #032f62;\">\" is a \"<\/span> + unitType + <span style=\"color: #032f62;\">\" that had &lt;b&gt;\"<\/span> +\r\n    <span style=\"color: #e36209;\">Text<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.RecreationalVisits_int, <span style=\"color: #032f62;\">\"#,###\"<\/span>) +\r\n    <span style=\"color: #032f62;\">\"&lt;\/b&gt; recreational visitors in 2022. This accounts for &lt;b&gt;\"<\/span> +\r\n    percentageValue + <span style=\"color: #032f62;\">\"&lt;\/b&gt; of visits to all national parks in 2022.\"<\/span>\r\n};\r\n<\/code><\/pre>\n"},{"acf_fc_layout":"content","content":"<p><a name=\"number\"><\/a><\/p>\n<h2>5. Number<\/h2>\n<p>The <a href=\"https:\/\/developers.arcgis.com\/arcade\/function-reference\/math_functions\/#number\">Number<\/a> function converts an input value of any type to a number. People often request a function to return the the number of milliseconds since Jan. 1, 1970 similar to JavaScript&#8217;s <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Date\/getTime\">Date.getTime()<\/a> method. This function already exists! <code>Number<\/code> will do this if you pass a date value as a parameter to the function.<\/p>\n<pre><code><span style=\"color: #e36209;\">Number<\/span>(<span style=\"color: #e36209;\">Date<\/span>())\r\n<span style=\"color: #6a737d;\">\/\/ returns epoch value<\/span>\r\n<\/code><\/pre>\n<p>It&#8217;s also common for people to store binary values as a feature attribute. Some attributes are either true or false, so the value will either be stored as a 0 (false) or 1 (true).<\/p>\n<p>I&#8217;ve seen some expressions do the following when calculating a value in editing workflows:<\/p>\n<pre><code><span style=\"color: #e36209;\">IIF<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.status == <span style=\"color: #032f62;\">\"completed\"<\/span>, <span style=\"color: #005cc5;\">1<\/span>, <span style=\"color: #005cc5;\">0<\/span>);\r\n<\/code><\/pre>\n<p>While this works, you can also leverage Number to return a 1 or a 0 when evaluating a Boolean expression.<\/p>\n<pre><code><span style=\"color: #e36209;\">Number<\/span>(<span style=\"color: #e36209;\">$feature<\/span>.status == <span style=\"color: #032f62;\">\"completed\"<\/span>);\r\n<span style=\"color: #6a737d;\">\/\/ returns 1 if true, 0 if false<\/span>\r\n<\/code><\/pre>\n<p>This is actually how the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/\">ArcGIS Maps SDK for JavaScript<\/a> calculates the sum of each category when visualizing <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/sample-code\/featurereduction-cluster-pie-charts\/\">clusters as pie charts<\/a>.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":1948852,"id":1948852,"title":"Screenshot 2023-06-01 at 5.12.26 PM","filename":"Screenshot-2023-06-01-at-5.12.26-PM.png","filesize":57563,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-06-01-at-5.12.26-PM.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions\/screenshot-2023-06-01-at-5-12-26-pm","alt":"Aggregate field calculated for use in a cluster's pie chart. The expression here evaluates for all features in the cluster. If the complaint type is \"Blocked Driveway\", the expression returns 1 for the feature. All values are summed resulting in the total count of blocked driveway complaints within the cluster.","author":"6561","description":"","caption":"Aggregate field calculated for use in a cluster's pie chart. The expression here evaluates for all features in the cluster. If the complaint type is \"Blocked Driveway\", the expression returns 1 for the feature. All values are summed resulting in the total count of blocked driveway complaints within the cluster.","name":"screenshot-2023-06-01-at-5-12-26-pm","status":"inherit","uploaded_to":1946822,"date":"2023-06-02 00:13:25","modified":"2023-06-02 00:15:40","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":817,"height":240,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-06-01-at-5.12.26-PM-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-06-01-at-5.12.26-PM.png","medium-width":464,"medium-height":136,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-06-01-at-5.12.26-PM.png","medium_large-width":768,"medium_large-height":226,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-06-01-at-5.12.26-PM.png","large-width":817,"large-height":240,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-06-01-at-5.12.26-PM.png","1536x1536-width":817,"1536x1536-height":240,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-06-01-at-5.12.26-PM.png","2048x2048-width":817,"2048x2048-height":240,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-06-01-at-5.12.26-PM.png","card_image-width":817,"card_image-height":240,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/06\/Screenshot-2023-06-01-at-5.12.26-PM.png","wide_image-width":817,"wide_image-height":240}},"image_position":"center","orientation":"horizontal","hyperlink":""},{"acf_fc_layout":"content","content":"<p><code>Number<\/code> can also be helpful if you need to parse a value from text and convert to a number for a calculation or number visualization.<\/p>\n<pre><code><span style=\"color: #e36209;\">Number<\/span>(<span style=\"color: #032f62;\">\"38.7%\"<\/span>, <span style=\"color: #032f62;\">\"#.#%\"<\/span>);\r\n<span style=\"color: #6a737d;\">\/\/ returns 0.387<\/span>\r\n\r\n<span style=\"color: #e36209;\">Number<\/span>(<span style=\"color: #032f62;\">\"1,000 people\"<\/span>, <span style=\"color: #032f62;\">\"# people\"<\/span>);\r\n<span style=\"color: #6a737d;\">\/\/ returns 1000<\/span>\r\n<\/code><\/pre>\n"},{"acf_fc_layout":"content","content":"<h2>The most under-appreciated function may be your own<\/h2>\n<p>If you find yourself writing duplicate code within one expression, you will likely benefit from writing a <a href=\"https:\/\/developers.arcgis.com\/arcade\/guide\/functions\/#user-defined-functions\">custom function<\/a>. Functions allow you to write would-be duplicate code once and give it an identifier. This significantly reduces errors that creep in with copy\/paste and can greatly reduce the size of an expression.<\/p>\n<p>In one extreme case, I was shown an expression longer than 900 lines in length that was eventually condensed to 22 lines just by defining a custom function and calling it in a <a href=\"https:\/\/developers.arcgis.com\/arcade\/guide\/loops\/#for\">for loop<\/a>.<\/p>\n"},{"acf_fc_layout":"content","content":"<h2>Conclusion<\/h2>\n<p>As with any other scripting or expression language, there are multiple ways to solve a task or come to a correct result. However, the functions described in this post (<code>iif<\/code>, <code>Text<\/code>, <code>Decode<\/code>, <code>DefaultValue<\/code>, <code>Number<\/code>) can simplify your expressions, improve their readability, and reduce bugs. Defining your own functions can also save you time, reduce the length of your expressions, and reduce bugs introduced in copy\/paste operations.<\/p>\n"}],"authors":[{"ID":6561,"user_firstname":"Kristian","user_lastname":"Ekenes","nickname":"Kristian Ekenes","user_nicename":"kekenes","display_name":"Kristian Ekenes","user_email":"KEkenes@esri.com","user_url":"https:\/\/github.com\/ekenes","user_registered":"2018-03-02 00:18:32","user_description":"Kristian Ekenes is a Principal Product Engineer at Esri specializing in data visualization on the web. He works on the ArcGIS Maps SDK for JavaScript, ArcGIS Arcade, and Map Viewer in ArcGIS Online. Kristian's work focuses on researching and developing new and innovative data visualization capabilities of geospatial data in web maps, Arcade integration in web maps, and applications of generative AI assistants in web maps. Prior to joining Esri, he worked as a GIS Specialist for an environmental consulting company. Kristian has degrees from Brigham Young University and Arizona State University.","user_avatar":"<img data-del=\"avatar\" src='https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/10\/ekenes-zurich-213x200.png' class='avatar pp-user-avatar avatar-96 photo ' height='96' width='96'\/>"}],"related_articles":[{"ID":878991,"post_author":"6461","post_date":"2020-06-10 11:11:30","post_date_gmt":"2020-06-10 18:11:30","post_content":"","post_title":"Your Arcade Questions Answered","post_excerpt":"","post_status":"publish","comment_status":"open","ping_status":"closed","post_password":"","post_name":"your-arcade-questions-answered","to_ping":"","pinged":"","post_modified":"2024-11-01 00:17:42","post_modified_gmt":"2024-11-01 07:17:42","post_content_filtered":"","post_parent":0,"guid":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=878991","menu_order":0,"post_type":"blog","post_mime_type":"","comment_count":"2","filter":"raw"},{"ID":1683632,"post_author":"6561","post_date":"2022-08-16 09:00:52","post_date_gmt":"2022-08-16 16:00:52","post_content":"","post_title":"I\u2019m a developer. Do I really need Arcade?","post_excerpt":"","post_status":"publish","comment_status":"open","ping_status":"closed","post_password":"","post_name":"im-a-developer-do-i-really-need-arcade","to_ping":"","pinged":"","post_modified":"2024-10-31 23:59:49","post_modified_gmt":"2024-11-01 06:59:49","post_content_filtered":"","post_parent":0,"guid":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=1683632","menu_order":0,"post_type":"blog","post_mime_type":"","comment_count":"0","filter":"raw"},{"ID":76991,"post_author":"6561","post_date":"2017-05-23 07:00:12","post_date_gmt":"2017-05-23 07:00:12","post_content":"","post_title":"Creating a predominance visualization with Arcade","post_excerpt":"","post_status":"publish","comment_status":"closed","ping_status":"closed","post_password":"","post_name":"creating-a-predominance-visualization-with-arcade","to_ping":"","pinged":"","post_modified":"2024-11-11 12:39:59","post_modified_gmt":"2024-11-11 20:39:59","post_content_filtered":"","post_parent":0,"guid":"http:\/\/www.esri.com\/arcgis-blog\/products\/product\/uncategorized\/creating-a-predominance-visualization-with-arcade\/","menu_order":0,"post_type":"blog","post_mime_type":"","comment_count":"0","filter":"raw"}],"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/card-arcade-2.jpg","wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/10\/arcWide.jpg"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Five under-appreciated Arcade functions<\/title>\n<meta name=\"description\" content=\"These five functions will save you time, simplify your expressions, improve their readability, and reduce bugs.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Five under-appreciated Arcade functions\" \/>\n<meta property=\"og:description\" content=\"These five functions will save you time, simplify your expressions, improve their readability, and reduce bugs.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions\" \/>\n<meta property=\"og:site_name\" content=\"ArcGIS Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/esrigis\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T06:57:36+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@ESRI\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions\"},\"author\":{\"name\":\"Kristian Ekenes\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/5469f723fbfb78138efbb1da56e6aa9b\"},\"headline\":\"Five under-appreciated Arcade functions\",\"datePublished\":\"2023-06-06T17:01:58+00:00\",\"dateModified\":\"2024-11-01T06:57:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions\"},\"wordCount\":4,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"keywords\":[\"arcade\",\"data visualization\",\"popups\"],\"articleSection\":[\"Arcade\",\"Developers\",\"Mapping\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions\",\"name\":\"Five under-appreciated Arcade functions\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\"},\"datePublished\":\"2023-06-06T17:01:58+00:00\",\"dateModified\":\"2024-11-01T06:57:36+00:00\",\"description\":\"These five functions will save you time, simplify your expressions, improve their readability, and reduce bugs.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.esri.com\/arcgis-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Five under-appreciated Arcade functions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"name\":\"ArcGIS Blog\",\"description\":\"Get insider info from Esri product teams\",\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\",\"name\":\"Esri\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"contentUrl\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"width\":400,\"height\":400,\"caption\":\"Esri\"},\"image\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/esrigis\/\",\"https:\/\/x.com\/ESRI\",\"https:\/\/www.linkedin.com\/company\/5311\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/5469f723fbfb78138efbb1da56e6aa9b\",\"name\":\"Kristian Ekenes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/10\/ekenes-zurich-213x200.png\",\"contentUrl\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/10\/ekenes-zurich-213x200.png\",\"caption\":\"Kristian Ekenes\"},\"description\":\"Kristian Ekenes is a Principal Product Engineer at Esri specializing in data visualization on the web. He works on the ArcGIS Maps SDK for JavaScript, ArcGIS Arcade, and Map Viewer in ArcGIS Online. Kristian's work focuses on researching and developing new and innovative data visualization capabilities of geospatial data in web maps, Arcade integration in web maps, and applications of generative AI assistants in web maps. Prior to joining Esri, he worked as a GIS Specialist for an environmental consulting company. Kristian has degrees from Brigham Young University and Arizona State University.\",\"sameAs\":[\"https:\/\/github.com\/ekenes\",\"https:\/\/www.linkedin.com\/in\/kristian-ekenes\/\",\"https:\/\/x.com\/kekenes\"],\"gender\":\"male\",\"jobTitle\":\"Principal Product Engineer\",\"worksFor\":\"Esri\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/author\/kekenes\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Five under-appreciated Arcade functions","description":"These five functions will save you time, simplify your expressions, improve their readability, and reduce bugs.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions","og_locale":"en_US","og_type":"article","og_title":"Five under-appreciated Arcade functions","og_description":"These five functions will save you time, simplify your expressions, improve their readability, and reduce bugs.","og_url":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions","og_site_name":"ArcGIS Blog","article_publisher":"https:\/\/www.facebook.com\/esrigis\/","article_modified_time":"2024-11-01T06:57:36+00:00","twitter_card":"summary_large_image","twitter_site":"@ESRI","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions#article","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions"},"author":{"name":"Kristian Ekenes","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/5469f723fbfb78138efbb1da56e6aa9b"},"headline":"Five under-appreciated Arcade functions","datePublished":"2023-06-06T17:01:58+00:00","dateModified":"2024-11-01T06:57:36+00:00","mainEntityOfPage":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions"},"wordCount":4,"commentCount":0,"publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"keywords":["arcade","data visualization","popups"],"articleSection":["Arcade","Developers","Mapping"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions","url":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions","name":"Five under-appreciated Arcade functions","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#website"},"datePublished":"2023-06-06T17:01:58+00:00","dateModified":"2024-11-01T06:57:36+00:00","description":"These five functions will save you time, simplify your expressions, improve their readability, and reduce bugs.","breadcrumb":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-online\/mapping\/five-under-appreciated-arcade-functions#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.esri.com\/arcgis-blog\/"},{"@type":"ListItem","position":2,"name":"Five under-appreciated Arcade functions"}]},{"@type":"WebSite","@id":"https:\/\/www.esri.com\/arcgis-blog\/#website","url":"https:\/\/www.esri.com\/arcgis-blog\/","name":"ArcGIS Blog","description":"Get insider info from Esri product teams","publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization","name":"Esri","url":"https:\/\/www.esri.com\/arcgis-blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","contentUrl":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","width":400,"height":400,"caption":"Esri"},"image":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/esrigis\/","https:\/\/x.com\/ESRI","https:\/\/www.linkedin.com\/company\/5311\/"]},{"@type":"Person","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/5469f723fbfb78138efbb1da56e6aa9b","name":"Kristian Ekenes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/","url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/10\/ekenes-zurich-213x200.png","contentUrl":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/10\/ekenes-zurich-213x200.png","caption":"Kristian Ekenes"},"description":"Kristian Ekenes is a Principal Product Engineer at Esri specializing in data visualization on the web. He works on the ArcGIS Maps SDK for JavaScript, ArcGIS Arcade, and Map Viewer in ArcGIS Online. Kristian's work focuses on researching and developing new and innovative data visualization capabilities of geospatial data in web maps, Arcade integration in web maps, and applications of generative AI assistants in web maps. Prior to joining Esri, he worked as a GIS Specialist for an environmental consulting company. Kristian has degrees from Brigham Young University and Arizona State University.","sameAs":["https:\/\/github.com\/ekenes","https:\/\/www.linkedin.com\/in\/kristian-ekenes\/","https:\/\/x.com\/kekenes"],"gender":"male","jobTitle":"Principal Product Engineer","worksFor":"Esri","url":"https:\/\/www.esri.com\/arcgis-blog\/author\/kekenes"}]}},"text_date":"June 6, 2023","author_name":"Kristian Ekenes","author_page":"https:\/\/www.esri.com\/arcgis-blog\/author\/kekenes","custom_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/10\/arcWide.jpg","primary_product":"ArcGIS Online","tag_data":[{"term_id":32551,"name":"arcade","slug":"arcade","term_group":0,"term_taxonomy_id":32551,"taxonomy":"post_tag","description":"","parent":0,"count":113,"filter":"raw"},{"term_id":30111,"name":"data visualization","slug":"data-visualization","term_group":0,"term_taxonomy_id":30111,"taxonomy":"post_tag","description":"","parent":0,"count":97,"filter":"raw"},{"term_id":212872,"name":"popups","slug":"popups","term_group":0,"term_taxonomy_id":212872,"taxonomy":"post_tag","description":"","parent":0,"count":12,"filter":"raw"}],"category_data":[{"term_id":777102,"name":"Arcade","slug":"arcade","term_group":0,"term_taxonomy_id":777102,"taxonomy":"category","description":"","parent":0,"count":98,"filter":"raw"},{"term_id":738191,"name":"Developers","slug":"developers","term_group":0,"term_taxonomy_id":738191,"taxonomy":"category","description":"","parent":0,"count":426,"filter":"raw"},{"term_id":22941,"name":"Mapping","slug":"mapping","term_group":0,"term_taxonomy_id":22941,"taxonomy":"category","description":"","parent":0,"count":2698,"filter":"raw"}],"product_data":[{"term_id":761642,"name":"ArcGIS Location Platform","slug":"platform","term_group":0,"term_taxonomy_id":761642,"taxonomy":"product","description":"","parent":36601,"count":215,"filter":"raw"},{"term_id":36831,"name":"ArcGIS Maps SDK for JavaScript","slug":"js-api-arcgis","term_group":0,"term_taxonomy_id":36831,"taxonomy":"product","description":"","parent":36601,"count":363,"filter":"raw"},{"term_id":36551,"name":"ArcGIS Online","slug":"arcgis-online","term_group":0,"term_taxonomy_id":36551,"taxonomy":"product","description":"","parent":0,"count":2433,"filter":"raw"},{"term_id":36601,"name":"Developers","slug":"developers","term_group":0,"term_taxonomy_id":36601,"taxonomy":"product","description":"","parent":0,"count":765,"filter":"raw"}],"primary_product_link":"https:\/\/www.esri.com\/arcgis-blog\/?s=#&products=arcgis-online","_links":{"self":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/1946822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/users\/6561"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/comments?post=1946822"}],"version-history":[{"count":0,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/1946822\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/media?parent=1946822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/categories?post=1946822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/tags?post=1946822"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/industry?post=1946822"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/product?post=1946822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}