Select to view content in your preferred language

Conditional Field Display in Pop Ups

3840
4
Jump to solution
04-13-2021 07:52 AM
AmandaBeck
Regular Contributor

Hello Everyone, 

So, I want to use Conditional Field Display with Arcade in my Pop-Ups. I have done all the reading and research I could find, but I can't seem to figure it out. 

Here is the link to my current map, it is public, showing my current pop ups, as a custom attribute expression I created. 

https://warrencountyny.maps.arcgis.com/apps/webappviewer/index.html?id=c29ab0ced8fe463e90cf22c7a20c0...

You'll notice that in the pop ups, certain amounts are set to 0, this is the value if no value is inputted into the table. There are some locations that won't get certain types of fish, and that's where I would like to have certain things not show in my pop up. 

 

For example: 

Mill Creek, rte 28 bridge downstream 1 mi was stocked with 575 spring yearling Brook Trout on 4/9/2021, 1:57 PM and 58 2 year old Brook Trout on 4/9/2021, 1:57 PM. It was also stocked with 0 spring yearling Rainbow Trout on  and 0 2 year old Rainbow Trout on . There were also 0 fall stock yearling Rainbow Trout stocked on .
 
This pop up should only read "Mill Creek, rte 28 bridge downstream 1 mi was stocked with 575 spring yearling Brook Trout on 4/9/2021 and 58 2 year old Brook Trout on 4/9/2021."
 
Here's a different location's pop up as is:
Clendon Brook was stocked with 100 spring yearling Brook Trout on 4/1/2021, 9:46 AM and 0 2 year old Brook Trout on . It was also stocked with 0 spring yearling Rainbow Trout on  and 0 2 year old Rainbow Trout on . There were also 0 fall stock yearling Rainbow Trout stocked on .
 
This pop up should only read "Clendon Brook was stocked with 100 spring yearling Brook Trout on 4/1/2021."
 
I have tried the IIF() function in Arcade, and have learned how to enter it while configuring the pop up using HTML, but haven't had any luck with coming out with what I actually want people to be able to see in my map. 
 
 
Is there someone out there that can help me? 
 
Thanks so much in advance!
 
 
 
 
0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

For each of your fish species, create an Arcade expression:

 

// show_fish_species_1
// returns 'inline' if the field is not empty, else 'none'

// If your empty fields are filled with 0, use this
return IIF($feature.FishSpecies1 == 0, 'none', 'inline')
// If your empty fields are empty, use this
return IIF(IsEmpty($feature.FishSpecies1), 'none', 'inline')
// Or just do both
return IIF(IsEmpty($feature.FishSpecies1) || $feature.FishSpecies1 == 0, 'none', 'inline')

 

Edit the HTML source of you popup (your example sentences seem a little too complex to do this way, so I remodeled a bit):

 

{Location} was stocked
<div style="display:{expression/show_brook_trout_1};">
 with {BrookTrout1} spring yearling Brook Trout on {SurveyDate1},
</div>
<div style="display:{expression/show_brook_trout_2};">
 with {BrookTrout2} 2 year old Brook Trout on {SurveyDate2},
</div>
<div style="display:{expression/show_raibow_trout_1};">
 with {RainbowTrout1} spring yearling Rainbow Trout on {SurveyDate3},
</div>
<div style="display:{expression/show_raibow_trout_2};">
 and with {RainbowTrout2} 2 year old Rainbow Trout on {SurveyDate4},
</div>
.

 

If you always survey all fish of the same species, you can do

 

{Location} was stocked
<div style="display:{expression/show_brook_trout};">
 with {BrookTrout1} spring yearling Brook Trout on {SurveyDate1} and {BrookTrout2} 2 year old Brook Trout on {SurveyDate2}.
</div>
<div style="display:{expression/show_raibow_trout};">
It was also stocked with {RainbowTrout1} spring yearling Rainbow Trout on {SurveyDate3} and with {RainbowTrout2} 2 year old Rainbow Trout on {SurveyDate4}.
</div>
.

 

The basic idea is simple: put parts of the text in <div> tags and show or hide these (display: inline/none) according to your number fields. Depending on the structure of your surveys and popup sentences, it could get pretty complex.


Have a great day!
Johannes

View solution in original post

4 Replies
RickeyFight
MVP Regular Contributor

@AmandaBeck Can you post the arcade script you have so far? 

0 Kudos
AmandaBeck
Regular Contributor

@RickeyFight 

I don't have one yet, I am just starting out. All I have is a custom attribute display of the information I want presented when a pop up is open. My issue is having certain information not show if the data in my table is 0, or not present at all. 

 

Here's my custom attribute display as of now: 

{Waterbody} was stocked with {STY} spring yearling Brook Trout on {STY_Date} and {ST2Y} 2 year old Brook Trout on {ST2Y_Date}. It was also stocked with {RTY} spring yearling Rainbow Trout on {RTY_Date} and {RT2Y} 2 year old Rainbow Trout on {RT2Y_Date}. There were also {RTFY} fall stock yearling Rainbow Trout stocked on {RTFY_Date}.

0 Kudos
JohannesLindner
MVP Frequent Contributor

For each of your fish species, create an Arcade expression:

 

// show_fish_species_1
// returns 'inline' if the field is not empty, else 'none'

// If your empty fields are filled with 0, use this
return IIF($feature.FishSpecies1 == 0, 'none', 'inline')
// If your empty fields are empty, use this
return IIF(IsEmpty($feature.FishSpecies1), 'none', 'inline')
// Or just do both
return IIF(IsEmpty($feature.FishSpecies1) || $feature.FishSpecies1 == 0, 'none', 'inline')

 

Edit the HTML source of you popup (your example sentences seem a little too complex to do this way, so I remodeled a bit):

 

{Location} was stocked
<div style="display:{expression/show_brook_trout_1};">
 with {BrookTrout1} spring yearling Brook Trout on {SurveyDate1},
</div>
<div style="display:{expression/show_brook_trout_2};">
 with {BrookTrout2} 2 year old Brook Trout on {SurveyDate2},
</div>
<div style="display:{expression/show_raibow_trout_1};">
 with {RainbowTrout1} spring yearling Rainbow Trout on {SurveyDate3},
</div>
<div style="display:{expression/show_raibow_trout_2};">
 and with {RainbowTrout2} 2 year old Rainbow Trout on {SurveyDate4},
</div>
.

 

If you always survey all fish of the same species, you can do

 

{Location} was stocked
<div style="display:{expression/show_brook_trout};">
 with {BrookTrout1} spring yearling Brook Trout on {SurveyDate1} and {BrookTrout2} 2 year old Brook Trout on {SurveyDate2}.
</div>
<div style="display:{expression/show_raibow_trout};">
It was also stocked with {RainbowTrout1} spring yearling Rainbow Trout on {SurveyDate3} and with {RainbowTrout2} 2 year old Rainbow Trout on {SurveyDate4}.
</div>
.

 

The basic idea is simple: put parts of the text in <div> tags and show or hide these (display: inline/none) according to your number fields. Depending on the structure of your surveys and popup sentences, it could get pretty complex.


Have a great day!
Johannes
AmandaBeck
Regular Contributor

Thank you @JohannesLindner  

This gave me an overview of how to use Arcade Expressions and how I wanted to display my data. I think I understand how it works now, I'll just have to do some tweaking but this explanation was greatly appreciated!