Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agegroup when arcade #25

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions any/when_agegroup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# when_agegroup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using this text for the link is fine, but can you format this so it's more readable? Maybe something like "Date to age group" or something that describes the function to be used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized this doesn't deal with Date fields. It's still numbers...so it could be even more generic, like "Number to category"


This expression assigns a value of a certain age group based on the value of a number column.

## Use cases

To categorize your age data into age groups for easier analysis and visualization.

## Workflow

Create a new field of type "String" in your feature layer and name it "AgeGroup". In the "field calculator" create the following Arcade expression:

// replace "applicant_age" with the name of a number
// field in your layer
var numberField = $feature["applicant_age"];

When(
numberField < 15, 'Under 15',
numberField >= 15 && numberField < 25, '16-25',
'NA' );

In the above expression we only had two categories ('Under 15' and '16-25') but you can add as many categories as needed.

You need to always have a default value at the end of expression (in our example - 'NA') or you will recieve an error.