How to create a year selector from a date field in Dashboard

332
2
Jump to solution
01-14-2021 01:33 AM
RachelScott
Occasional Contributor III

Hi,

I'd like to create a year selector on the dashboard using a date field I have.

Can this be done or do I need to create a year field in Survey123 connect. If I do how do I do that and ensure it's hidden.

 

Thanks

Rachel

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Regular Contributor

Without a "year" field, this can be fairly tedious, but it's possible.

Without Adding a Field

  1. Create a Date Selector
  2. Set Type to Defined Options
  3. Add an option YYYY with two criteria
    1. "is or is after", choose Value, 1/1/YYYY
    2. "is or is before", choose Value, 12/31/YYYY
  4. Repeat for as many years as you have

jCarlson_0-1610633915568.png

If your dataset has lots of years, this is a very unappealing option. Add to it the fact that you can't reorder the choices, so you'd better do them in ascending order, or future years will be at the bottom of the list out of sequence.

 

Adding a Year Field: Update w/ Field Calculator

An alternative would be to add such a field and periodically use the Field Calculator to populated it based on the date field.

jCarlson_1-1610634168936.png

Such a task could be scheduled easily enough with the arcgis python module.

 

Adding a Year Field: Update Via Survey123 Connect

Pulling the year out of a date field in Survey123 is not too difficult. With a 'year' field in place, use the format-date() expression in the calculation and default fields of the XLS speadsheet:

format-date(now(), '%Y')

or

format-date(${some-other-field}, '%Y')

Whichever of those expressions meets your needs. Then set the type column to "hidden". End users will not see the "year" field, but it will be included in form submissions.

Screenshot 2021-01-14 084347.png

 

Oh and lastly. I don't know if it'll let you, but do not name your field "year", as that can mess up some internal stuff, it being a "reserved keyword".

However you do it, with a specific field corresponding to the year, you simply create a Category Selector, select Grouped Values, then choose your year field as the Category Field. Then your selector will auto-populated with new values as submissions come in.

- Josh Carlson
Kendall County GIS

View solution in original post

2 Replies
jcarlson
MVP Regular Contributor

Without a "year" field, this can be fairly tedious, but it's possible.

Without Adding a Field

  1. Create a Date Selector
  2. Set Type to Defined Options
  3. Add an option YYYY with two criteria
    1. "is or is after", choose Value, 1/1/YYYY
    2. "is or is before", choose Value, 12/31/YYYY
  4. Repeat for as many years as you have

jCarlson_0-1610633915568.png

If your dataset has lots of years, this is a very unappealing option. Add to it the fact that you can't reorder the choices, so you'd better do them in ascending order, or future years will be at the bottom of the list out of sequence.

 

Adding a Year Field: Update w/ Field Calculator

An alternative would be to add such a field and periodically use the Field Calculator to populated it based on the date field.

jCarlson_1-1610634168936.png

Such a task could be scheduled easily enough with the arcgis python module.

 

Adding a Year Field: Update Via Survey123 Connect

Pulling the year out of a date field in Survey123 is not too difficult. With a 'year' field in place, use the format-date() expression in the calculation and default fields of the XLS speadsheet:

format-date(now(), '%Y')

or

format-date(${some-other-field}, '%Y')

Whichever of those expressions meets your needs. Then set the type column to "hidden". End users will not see the "year" field, but it will be included in form submissions.

Screenshot 2021-01-14 084347.png

 

Oh and lastly. I don't know if it'll let you, but do not name your field "year", as that can mess up some internal stuff, it being a "reserved keyword".

However you do it, with a specific field corresponding to the year, you simply create a Category Selector, select Grouped Values, then choose your year field as the Category Field. Then your selector will auto-populated with new values as submissions come in.

- Josh Carlson
Kendall County GIS

View solution in original post

RachelScott
Occasional Contributor III

Josh, thank you so much.

I added the field year_ into Survey123 and just sent a test and it successfully updated the year field..

Now to update all my dashboards with year options.

Thanks again for such a comprehensive reply.

Rachel

0 Kudos