<?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: Arcade (or other) expression to create multi-line label with variable entries in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-or-other-expression-to-create-multi-line/m-p/1216462#M60330</link>
    <description>&lt;P&gt;You're very welcome!&lt;/P&gt;&lt;P&gt;I'd suggest a few things:&lt;/P&gt;&lt;OL class="lia-list-style-type-upper-alpha"&gt;&lt;LI&gt;Checking out the Arcade GitHub repo: &lt;A href="https://github.com/Esri/arcade-expressions/" target="_blank"&gt;https://github.com/Esri/arcade-expressions/&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Just messing around on the Arcade Playground: &lt;A href="https://developers.arcgis.com/arcade/playground/" target="_blank"&gt;https://developers.arcgis.com/arcade/playground/&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Making a layer / map / dashboard that's specifically for just messing around with Arcade, and see what you can make with it.&lt;/LI&gt;&lt;/OL&gt;</description>
    <pubDate>Tue, 27 Sep 2022 12:49:04 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2022-09-27T12:49:04Z</dc:date>
    <item>
      <title>Arcade (or other) expression to create multi-line label with variable entries</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-or-other-expression-to-create-multi-line/m-p/1215985#M60242</link>
      <description>&lt;P&gt;Any help appreciated. I am trying to write an expression that will create a label based on presence or absence of data across a number of fields.&lt;/P&gt;&lt;P&gt;I want the label to include the following:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Location Name&lt;/STRONG&gt; - from field&lt;/LI&gt;&lt;LI&gt;IF ItemCount != 0 THEN &lt;STRONG&gt;add a new line with a text label and then the ItemCount value&lt;/STRONG&gt; ELSE go to next item&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;There are 9 or more items.&amp;nbsp;&lt;/P&gt;&lt;P&gt;eg for the Home location with 2 cars, 4 bikes, and 1 boat the label would look like:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Home&lt;/LI&gt;&lt;LI&gt;Car: 2&lt;/LI&gt;&lt;LI&gt;Bike: 4&lt;/LI&gt;&lt;LI&gt;Boat: 1&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;However, if no bikes or boat, then the label would be as below with no extra lines:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Home&lt;/LI&gt;&lt;LI&gt;Car: 2&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The data fields are setup similar to this&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;OID / LOCATION / CAR_count / BIKE_count / BOAT_count&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Using Arcade I was able to build a multi-line label by using:&lt;/P&gt;&lt;P&gt;Concatenate([&lt;BR /&gt;&amp;nbsp; $feature.LOCATION,&lt;BR /&gt;&amp;nbsp; 'Car: ' + $feature.CAR_count,&lt;BR /&gt;&amp;nbsp; 'Bike: ' + $feature.BIKE_count,&lt;BR /&gt;&amp;nbsp; 'Boat: ' + $featureBOAT_count],&lt;BR /&gt;&amp;nbsp; TextFormatting.NewLine)&lt;/P&gt;&lt;P&gt;This works fine and outputs a count for all 3 types even when the count is zero. I need to find a way to only add a line when the count is greater than zero. This will simplify the map by reducing the entries in the labels when only 1 or 2 of the 9 (or more) data fields are present.&lt;/P&gt;&lt;P&gt;The solution doesn't have to be using Arcade, could be VBscript, JScript, or Python if you have an easy solution.&lt;/P&gt;&lt;P&gt;Many thanks, Pete&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 10:27:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-or-other-expression-to-create-multi-line/m-p/1215985#M60242</guid>
      <dc:creator>peterverwey_ses</dc:creator>
      <dc:date>2022-09-26T10:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade (or other) expression to create multi-line label with variable entries</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-or-other-expression-to-create-multi-line/m-p/1216030#M60253</link>
      <description>&lt;P&gt;Simple enough! We can use &lt;STRONG&gt;push&lt;/STRONG&gt; to add entries to the array only when the condition is met.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var label_array = [$feature.LOCATION]

var counts = {
    'Car': $feature.CAR_count,
    'Bike': $feature.BIKE_count,
    'Boat': $feature.BOAT_count
}

for (var c in counts){
    if(counts[c]&amp;gt;0){
        Push(
            label_array,
            `\t${c}: ${counts[c]}`
        )
    }
}

return Concatenate(
    label_array,
    '\n'
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here's me testing that with some sample values:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_1-1664196544510.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52159i61F68B9BA5BACB9F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_1-1664196544510.png" alt="jcarlson_1-1664196544510.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 12:49:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-or-other-expression-to-create-multi-line/m-p/1216030#M60253</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-09-26T12:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade (or other) expression to create multi-line label with variable entries</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-or-other-expression-to-create-multi-line/m-p/1216333#M60311</link>
      <description>&lt;P&gt;Hi Josh,&lt;/P&gt;&lt;P&gt;You are a legend. Thank you.&lt;/P&gt;&lt;P&gt;Your solution worked first time and is simple and elegant. You have helped make a very messy map much cleaner and easier to read.&lt;/P&gt;&lt;P&gt;Can you suggest any good resources for learning more about arcade expressions like this?&lt;/P&gt;&lt;P&gt;Many thanks again.&lt;/P&gt;&lt;P&gt;Pete&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 23:09:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-or-other-expression-to-create-multi-line/m-p/1216333#M60311</guid>
      <dc:creator>peterverwey_ses</dc:creator>
      <dc:date>2022-09-26T23:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade (or other) expression to create multi-line label with variable entries</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-or-other-expression-to-create-multi-line/m-p/1216462#M60330</link>
      <description>&lt;P&gt;You're very welcome!&lt;/P&gt;&lt;P&gt;I'd suggest a few things:&lt;/P&gt;&lt;OL class="lia-list-style-type-upper-alpha"&gt;&lt;LI&gt;Checking out the Arcade GitHub repo: &lt;A href="https://github.com/Esri/arcade-expressions/" target="_blank"&gt;https://github.com/Esri/arcade-expressions/&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Just messing around on the Arcade Playground: &lt;A href="https://developers.arcgis.com/arcade/playground/" target="_blank"&gt;https://developers.arcgis.com/arcade/playground/&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Making a layer / map / dashboard that's specifically for just messing around with Arcade, and see what you can make with it.&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Tue, 27 Sep 2022 12:49:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-or-other-expression-to-create-multi-line/m-p/1216462#M60330</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-09-27T12:49:04Z</dc:date>
    </item>
  </channel>
</rss>

