"X Days Until Y" card

845
6
02-19-2020 01:10 PM
AmyRoust
Occasional Contributor III

I'm looking for a way to add a card to an Operations Dashboard, Sites, or Hub site that will dynamically count down the days until an event. It looks like it should be possible if I use an Indicator in Operations Dashboard because of the example they have on this page.

I can't figure out how to put in a formula that will dynamically subtract today's date from the date of the event and put that count of days in the Indicator.

6 Replies
michael_vetter
Occasional Contributor

Amy,

If you set a Reference value in the Indicator Data Options, then you can click Fields: {} in the Indicator Options and choose the Value - Reference {difference} option. This option will automatically update based on changes to the value or reference numbers.

Michael

0 Kudos
AmyRoust
Occasional Contributor III

That helps -- I wasn't able to make sense of the documentation, but you've clarified how it is supposed to work.

I wonder my problem is that Portal 10.7.1 doesn't support date fields in Indicators? When I click the drop-down to choose a field for my reference value, it tells me that I have "No matching options" in the feature:

I don't have any numeric fields in this feature class -- just text and dates -- so I'm guessing that it's looking for a short, long, or double field.

EDITED TO ADD: Looks like dates aren't supported, if this post on Geonet is correct. If that's the case, I wonder how they did the card in the example in my screenshot? There has to be math involved somewhere, or the ticker wouldn't be dynamic.

0 Kudos
michael_vetter
Occasional Contributor

Maybe try using Statistic as the Reference Type instead of Feature. I'm using Operations Dashboard through ArcGIS Online and it is allowing me to use date fields as long as I use Statistic as the Value Type.

0 Kudos
AmyRoust
Occasional Contributor III

Is your data coming from a Feature Layer? I'm wondering now if I need to republish the service in a different format because I can't get any of the fields to come up via Statistic. (I switched to AGOL, but the web service is coming from my server/portal)

0 Kudos
michael_vetter
Occasional Contributor

The layer I used to test to see if the date would work is a feature layer. However, it is a hosted layer and not on my server, but I wouldn't think that would make a difference.

0 Kudos
MJBiazar
Esri Contributor

Hi @AmyRoust,

 

As you noted in your post, this is possible by using an Arcade expression in an Indicator widget on a dashboard. In order to do this, you need to modify an existing Indicator widget and use an expression similar to the example below:

var startDate = Today();
var endDate = Date(2021,9,28);
var daysLeft = DateDiff(endDate, startDate,'day');

return {
middleText: daysLeft,
middleTextMaxSize: 'large',
bottomText: 'Days left...!',
}

 

This will calculate the difference between today's date and the end date that you specify in days and shows the results on your Indicator. These dates can be defined static dates or from the attributes of a feature layer or table used in your dashboard. Notice that when using the Date function, months are defined by 0-11 instead of 1-12 (e.g. 9 is October).

 

2021-10-26_8-01-21.jpg

 

Best,

MJ

0 Kudos