Select to view content in your preferred language

Arcade: hide symbol after closing date

283
3
Jump to solution
07-22-2025 12:52 PM
Labels (1)
JaredPilbeam2
MVP Alum

I have a Date only field called closingDate. How would I use that field in a Styles expression as a means to hide the symbol on the map when that date is over?

Something like this:

// Variable containing closing day of event
var closingDay = $feature.closingDate

// Variable containing today's date in date only format 
var todaysDate = DateOnly()

if (closingDay < todaysDate) {
    return null;
}
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

You can use this expression

iif ($feature.closingDate < DateOnly(), "No", "Yes")

And in the Styles dialog, move the "No" entry to the Other category and make sure it's turned off

View solution in original post

3 Replies
KenBuja
MVP Esteemed Contributor

You can use this expression

iif ($feature.closingDate < DateOnly(), "No", "Yes")

And in the Styles dialog, move the "No" entry to the Other category and make sure it's turned off

JaredPilbeam2
MVP Alum

Thanks @KenBuja, that works great. 

Alternatively, could you use When() and DateDiff functions? This is one way I've tried it, but it's not showing all of them.

// Variables containing the opening and closing days of the attraction 
var openingDay = $feature.Dateof
var closingDay = $feature.closingDate

// Variable containing today's date in date only format 
var todaysDate = DateOnly()

// Calculate the number of days between today and opening day 
var difDays = DateDiff(openingDay, todaysDate, 'days') //openingDay is a Date only field with opening dates

// Categorize feature based on date comparisons 
When( 
  difDays >= 14 || todaysDate > closingDay, 'Closed', 
  difDays > 0 && difDays < 15,'Opening soon',
  todaysDate > closingDay, 'Over',
  'Open' 
  ); 
0 Kudos
KenBuja
MVP Esteemed Contributor

Glad to help. Don't forget to check the Accept as Solution box.

The reason it may not be showing all of them is that the legends generated by Arcade will only give you the values that exist. If your data doesn't contain the values for each of the possibilities, you'll have to use dummy data to build it. Having said that, I don't see how you'll every get "Over" returned. If you changed line 13 to use && instead of ||, then you can get "Over"

You can simplify your expression also. In line 14, you don't need to check whether difDays is less than 15 since that was checked in line 13