20 - Preparing Your Metrics: Flight Alerts Per State

This content is also available at learn.palantir.com ↗ and is presented here for accessibility purposes.

If your flight alerts were directly linked to airports in the Ontology, this would be a straightforward matter of filtering airports by the selected state and then searching around for linked flight alerts. The fact that your flight alerts are only transitively linked to airports via the [Example Data] Flight object type complicates the path we need to take to create the needed variables.

In practice, an alternative to the compounding steps below would be to confer with your team and decide whether an Ontology change that places your flight alerts directly in touch with airports might be in order.

You’ll need to create four variables:

  1. [o] Airports in Selected State — we need a way to know which states have been selected, and the output filter of your choropleth map can be used to narrow in on the airports in the selected state.
  2. [s][a] Selected States — we can create a string array (hence "s") of unique Airport State Codes from the object set variable above. If we then select New York and California on the choropleth, the string array variable will be set to [NY, CA].
  3. [o] Flight Alerts in State — Since the [Example Data] Flight object type has the state codes (and your flight alerts don't), we'll start with your flight alerts, Search Around to their flights, and then filter by the array above.
  4. Finally, we'll create a new numeric aggregation variable that counts the objects in the object set in #3.

If this is a common operation we want to perform, we can see why an Ontology change would be preferable! Due to the relative complexity, we’ve provided the image below showing how the configurations fit together. In this example, the state of Florida (FL) has been selected on the choropleth. Use the image to supplement the instructions in the next two tasks as you work.

🔨 Task Instructions

  1. Click into the Variables panel on the left side of the screen and, using the ➕ button, create the [o] Airports in Selected State object set definition variable with [o] Filtered Airports for Map as the starting object set and [f] Map State Selection as the filter variable.
  2. Click ➕ again and choose ...Array, then String Array, and finally on Object set aggregation. Name the variable [s][a] Selected State and use [o] Airports in Selected State as the starting object set. Set Unique values as aggregation method and Airport State Code as the property.
  3. Click ➕ again and create the [o] Flight Alerts in Selected State object set definition variable with [o] Filtered Flight Alerts (COP) as the starting object set. Then get linked objects [Example Data] Flight and then filter on the Origin State Abbreviation property.
  4. When selecting the value for the Origin State Abbreviation property, click the (x) arrow below the property value field to reveal the string variables that can be used. Choose [s][a] Selected State.
  5. Click ➕ again and choose Numeric, then Object set aggregation. Name your variable [n] Flight Alerts in Selected States, then configure it to perform a count of [o] Flight Alerts in Selected State.
  6. Save and publish. Note that you may see warnings at the top of your screen advising that you have four unused variables. This is a helpful reminder to clean up any variables that are no longer used, but we're about to make use of these.