Metropolis Documentation 4.3 > Platform Concepts > Metric Reference > Metrics You Should Know |

There are thousands of metrics in Palantir. This page lists some of the most useful metrics that you may not already know about.

Name | Input | Output |
---|---|---|

Add | Collection | Collection |

Aggregate | Collection | Object |

ApplyToAll | Collection | Collection |

ApplyToAllValue | Collection | Collection |

Convert | TimeSeries | TimeSeries |

Correl | TimeSeries | TimeSeries |

EvaluateUsingProviders | None | Object |

Filter | Collection | Collection |

FirstDate | DateSet | Date |

Format | None | String |

Format | None | String |

Interpolate | TimeSeries | TimeSeries |

Intersect | Collection | ExplorerGroup |

Intersect | DateSet | DateSet |

Lag | TimeSeries | TimeSeries |

LastDate | DateSet | Date |

LookupModel | None | Model |

Members | Set | Set |

MembersAsOf | Set | Set |

PercentChange | TimeSeries | TimeSeries |

PercentReturnToLevel | TimeSeries | TimeSeries |

None | String | |

Sample | TimeSeries | TimeSeries |

Sign | TimeSeries | TimeSeries |

Slice | TimeSeries | TimeSeries |

Stitch | TimeSeries | TimeSeries |

To | Date | DateSet |

ToString | Object | String |

Until | Date | DateSet |

ValidDates | TimeSeries | DateSet |

Value | TimeSeries | Number |

ValueOn | TimeSeries | Number |

Collection -> Collection

*Description:*

Adds an element to a collection.

*Parameters:*

- Element: Object to add to the collection.

*Example:*

Set s = createSet(US, CA, MX) s.add(PR); //Adds Puerto Rico to the collection.

Collection -> Object

*Description:*

Aggregates a collection of items (such as a set of numbers, set of time series, or a dynamic group) into a single value or time series by applying the metric to each item in the group and combining the resulting numbers or time series based on the specified statistics.

Aggregate()works on a dynamic set -you provide the metric with start and end dates and also a sampling date set. Unlike other aggregating metrics in Palantir, such as aggregateSum(), aggregate() uses the sampling date parameter to rebalance the members of your group, making it dynamic.

*Parameters:*

- Statistic: set the combination method you want to apply to the collection, i.e. sum, mean, count, standard deviation. See the autocomplete window for a complete list of possible statistics.
- Value metric: indicate the metric you want to use to evaluate each item in the collection. For example, do you want to evaluate each object by its closing value or market capitalization?
- Start date and end date: set the time frame for the computation.
- Sampling date set: select a date set for the sampling frequency. Note that when evaluating over a dynamic group, this will also rebalance the group membership on those sampling dates.
- Lookback window: establish how far back in time the system should go in order to find a data point. The default of
`null`means that the system will look back indefinitely. - Lookback frequency: indicate the units of the lookback window. For example, if your lookback window is
`10`, a frequency of`daily`indicates that the system will look back 10 days. Note that the starting period of the lookback is each sampling date. - Weighting metric: select a metric that you want to use to weight each item in your collection. For example, enter
`marketCap()`to weight stocks with high market capitalization more heavily.

Statistic is the only parameter that is required in order to use this metric. |

*Example:*

**Set of numbers:**

For a set of numbers, the only parameter that you need to set is Statistic.

num=[3,6,123,2,4,1,1,223] num.aggregate(Enum.SUM) //returns the sum of all the numbers of your set, 363.0 num.aggregate(Enum.MEAN) //returns the mean of your set, 45.375 num.aggregate(Enum.STD_DEV) //returns the standard deviation of your set, 83.1985

**Set of time series:**

A set of time series is static by nature, meaning that the sampling date set parameter will not be used to rebalance the collection, but will only be used to sample data points. (See the screenshot below for the numerical results of the following queries.)

stocks=[GOOG,AAPL,MSFT] stocks.aggregate(Enum.SUM) //returns a time series that is the sum of the three stocks. As we did not set a value metric, //this uses the default of Google, Apple, and Microsoft's closing values to calculate the sum. stocks.aggregate(Enum.SUM, Metric.volume,today().addTime(-5,Enum.YEARS),today(),DateSet("Every Quarter")) //returns a time series of the sum of Google, Apple, and Microsoft's volumes, //sampled once every quarter over the last 5 years. stocks.aggregate(Enum.SUM, Metric.volume,today().addTime(-5,Enum.YEARS),today(), DateSet("Every Quarter"),10,Enum.DAYS,Metric.marketCap) /* *returns a time series of the sum of Google, Apple, and Microsoft's volumes, *sampled once every quarter over the last 5 years, with a lookback window of 10 days, *and weights each of the three stocks based on their market capitalization. *This answer is different from the previous answer because you added marketCap() as the weighting metric. */

**Dynamic Group:**

By definition, since this is a dynamic group, the membership of the group is subject to change, and therefore the sampling date set parameter will be used to both rebalance the group membership while also sampling the data points on those dates.

ExplorerGroup("Dow Jones Group").aggregate(Enum.MEAN,Metric.close, today().addTime(-1,Enum.Years),today,DateSet("Last Day of Month")) /* *returns a time series that represents the mean closing value of the members of the Dow Jones. *The membership is dynamically rebalanced on the last day of each month, *and the closing prices are also collected on those days. */ ExplorerGroup("Dow Jones Group").aggregate(Enum.MEAN,Metric.close,today().addTime(-1,Enum.YEARS), today,DateSet("Last Day of Month"),null,null,Metric.marketCap) //returns almost the same time series as in the previous example, //the difference is that this time the stocks in the Dow Jones are weighted by their marketCap().

Collection -> Collection

*Description:*

Applies the specified metric to all items in the input collection.

*Parameters:*

- Metric: The metric that is applied to all the items in the collection.

*Example:*

Set s = createSet(DE, FR, IT, PT) s.applyToAll(Metric.gdpPerCapita()) //Returns a collection of time series //with each time series representing the GDP per capita of Germany, France, Italy, and Portugal. average(INDU.applyToAll(Metric.pe.valueOn('2011-7-1',Enum.ON_OR_AFTER))) //Returns the average PE of the Dow Jones constituents after July 1, 2011

Collection -> Collection

*Description:*

Applies the specified metric to all items in the collection at the valueOn date. Unlike applyToAll(), this metric returns a value for each item in a collection, not a time series. If no date parameter is added, the metric defaults to the valueOn date.

*Parameters:*

- Metric: The metric that is applied to all the items in the collection.
- valueOnDate: The date for which to apply to the metric. If unspecified, uses the default ValueOn date.

*Example:*

Set s = createSet(DE, FR, IT, PT) s.applyToAllValue(Metric.gdpPerCapita(), '2005-01-01') //Returns a collection of values, //where each value is the GDP per capita of Germany, France, Italy, and Portugal //as of January 1, 2005

TimeSeries -> TimeSeries

*Description:*

Converts a time series to a specified currency.

*Parameters:*

- End Currency: Currency to convert to.
- ConvertEveryDay: If true, converts using all available fx rates, usually every day - i.e., the output TimeSeries will have a point every day even if the input series only has one per quarter/year/etc. If false (the default), the output series will only have values at times that the input series did.

*Example:*

` FR.grossDebt.convert(Currency:USD)`

TimeSeries -> TimeSeries

*Description:*

Returns the rolling correlation (Pearson product-moment correlation coefficient, or r) of the input time series with the time series specified as the first parameter. The size of the rolling window is specified by the numPeriods and frequency parameters. The correlation includes only points (dates/times) on which both the input series and the parameter series are defined.

Note, if you have a time series in which each point directly depends on the previous point (such as price, marketCap(), or total revenue since the year's start) then it does not make sense to take a correlation directly. Instead you need to take the derivative of that time series, and you can do this by adding percentChange().

*Parameters:*

- otherSeries: The series against which to correlate the input
- numPeriods: The number of data points or calendar periods to include in the rolling window
- periodType: Determines whether to use a point-based or calendar-based rolling window. If the parameter is not specified, the rolling window includes the specified number of data points. If specified, the rolling window includes all of the data points within the calendar window (which may vary as the window moves across the input series).

*Example:*

IBM.percentChange.correl(SPX.percentChange, 5, Enum.YEARS) // 5 years' worth of points, need the percentChange in order for a correlation to make sense IBM.volumeTraded.correl(MSFT.volumeTraded, 250) // 250-point correlation, no need for the percentChange() metric // since points in each time series do not depend on the previous point

None -> Object

*Description:*

Evaluates the specified expression by using the specified data provider(s).

*Parameters:*

- Expression: The expression to evaluate.
- Providers: A comma separated list of data providers.

*Example:*

In a typical QAStudio deployment, Datastream will have a higher priority than IDC. Therefore, if you open a Chart and enter `DEUTS65`, the system will return the default Datastream time series of closing prices.

If you then enter `evaluateUsingProviders(DEUTS65, QADIRECTIDCEQUITIES)`, the expression returns the IDC DEUTS65 model. However, because the models from Datastream and IDC resolve (i.e. the System recognizes them as the same model), Chart just sees DEUTS65 and doesn't know that it is IDC instead of Datastream. Therefore, when it outputs a plot, it uses the default Datastream close time series (since Datastream has higher priority than IDC).

In order to for Chart to output the closing time series of DEUTS65 using IDC, you must be explicit and use the more complete expression, `evaluateUsingProviders(DEUTS65.close, QADIRECTIDCEQUITIES)`. This expression returns a closing time series and Chart has nothing to decipher and can just plot the result as given.

Collection -> Collection

*Description:*

This filters a collection by applying the parameter metric to each element in the collection, and returning a set of elements for which that metric returned true.

*Parameters:*

- Metric: The metric to filter the collection on.

*Example:*

DateSet("Past Year").filter(metric : date -> boolean { SPX.percentChange().valueOn(this) > 0}) //returns all the days in the past year where the S&P has had a positive day over day percent change. ExplorerGroup("Dow Jones Group").filter(metric : Instrument -> Boolean { close().value() > 100 }) //returns a set of all stocks in the Dow with closing prices greater than 100. SPX.filter(metric : Instrument -> Boolean { employees > 350000 }) //returns a set of all the companies in the S&P that have more than 350,000 employees.

DateSet -> Date

*Description:*

Gets the first date in a DateSet. Returns null if the DateSet is empty.

*Parameters:*

None

*Example:*

DateSet("Past 3 Months").firstDate()

None -> String

*Description:*

Formats a number based on a given style. This metric behaves like Java's DecimalFormat class.

*Parameters:*

- number: The number to be formatted.
- style: The style to format with. See the pattern parameter in Java's DecimalFormat class for more details.

*Example:*

format(1.1, "$.00 US Dollars") /* * Returns $1.10 US Dollars * The dot is a decimal point * The zeroes are digits with leading and trailing zeroes. * Other characters pass through as-is. format(1000000.55, ", ###") * Returns 1, 000, 001 * The comma is a grouping separator. * The pound signs are digits without leading or trailing zeroes. * Notice the decimals are rounded up. format(-.1, "#%;(#%)") * Returns (10%) * The semicolon separates two styles: one for positive numbers and one for negative numbers. * The percent sign multiples the value by 100 and shows the percent sign. */

None -> String

*Description:*

Provides an sprintf-like metric for generating formatted strings.

*Parameters:*

- format: The format string
- fmtParams: The parameters to the format string

*Example:*

format("Student: %s. Grade 1: %d. Grade 2: %d. Average: %f", "John", 4, 3, (4+3)/2.0) // displays a students grade. format("Two decimal places rounded: %.2f", 2.24987324); format("Hello %s, my name is %s%n", "Joe", "Mary") // displays "Hello Joe, my name is Mary" followed by a newline.

TimeSeries -> TimeSeries

*Description:*

Fills in data values for the specified date range in a linear or fill-forward mode.

*Parameters:*

- Interpolation Days: DateSet to interpolate by.
- Interpolation Style: Set the interpolation method.

*Example:*

US.gdp.interpolate(DateSet("Every Month"), Enum.FILL_FORWARD).slice(US.gdp.startdate.to(US.gdp.enddate))

For more information, see Working with Time Series Data#Clipping Time Series.

Collection -> ExplorerGroup

*Description:*

Returns an ExplorerGroup that intersects the input collection with the specified collection by adding static or dynamic filters.

*Parameters:*

- Other collection: The collection to intersect with.

*Example:*

SPX.members().intersect(INDU.members())

DateSet -> DateSet

*Description:*

Create a DateSet that contains the intersection between two other DateSets.

*Parameters:*

- DateSet: The DateSet to intersect.

*Example:*

DateSet("Past 3 Years").intersect(DateSet("Wednesdays"))

TimeSeries -> TimeSeries

*Description:*

Returns a time series equal to the input time series shifted forward or backward in time. lag(20) shifts the series 20 points to the right, and lag(-20) shifts the series 20 points to the left. By default, the series is shifted by the specified number of points (i.e. trading days). To instead shift the series by a fixed calendar amount, specify the optional frequency parameter. lag(20, Enum.DAYS) shifts the series by 20 calendar days, and lag(20, Enum.MONTHS) shifts the series by 20 calendar months.

*Parameters:*

- numPeriods: Number of lagged periods
- frequency: Number of points or period to lag by. Default value of null lags using points instead of periods.

*Example:*

US.employment.lag(20) //the US employment series lagged 20 points to the right US.employment.lag(-20) //the US employment series lagged 20 points to the left US.employment.lag(20, Enum.DAYS) //the US employment series lagged 20 calendar days

DateSet -> Date

*Description:*

Returns the last date in a DateSet. Returns null if the DateSet is empty.

*Parameters:*

None

*Example:*

DateSet("Past 3 Months").lastDate()

None -> Model

*Description:*

Gets the model with the specified value. The property value should be unique to the model. If there are multiple model matches, the system attempts to disambiguate based on the valueOnDate of the property. If unable to disambiguate, the system throws an error.

Note that this will take some time to search through the entire system.

*Parameters:*

- ValueToMatch: The value to match.
- PropertyType: The Property Type to search over. If you do not specify the property type, the system defaults to model ID or UUID.

*Example:*

lookupModel("AMZN", Metric.symbol())

Set -> Set

*Description:*

Returns the members of a collection as of the valueOn date.

*Parameters:*

None

*Example:*

ExplorerGroup("Dow Jones Group").members()

Set -> Set

*Description:*

Returns all of the members of a collection as of the specified date.

*Parameters:*

- Date: The date to use for determining memebership.

*Example:*

ExplorerGroup("Dow Jones Group").membersAsOf('2001-01-01')

TimeSeries -> TimeSeries

*Description:*

Returns a time series where each point is the difference (in percentage terms) between two points in the input time series. percentChange(20) is the return over the past 20 points, and percentChange(-20) is the forward return over the future 20 points. By default, percentChange is calculated over the specified number of points (i.e. trading days). To instead calculate change over a fixed calendar period, specify the optional frequency parameter.

*Parameters:*

- numPeriods: The number of points over which to take the difference.
- frequency: Assigns an Enum value to the numPeriods.

*Example:*

GR.grossDebt.percentChange(20) //the percent difference in Greece's gross debt between now and 20 points backward in time GR.grossDebt.percentChange(-20) //the percent difference between 20 points forward and now GR.grossDebt.percentChange(20, enum.DAYS) //the percent difference over 20 calendar days

TimeSeries -> TimeSeries

*Description:*

Convert a percent return series to a level series.

*Parameters:*

- initialValue: The initial value
- startDate: The start date of the output series if it is before the first point of series, otherwise, start date will be the first date in input series on or after the start date
- inclusiveEndDate: Optional inclusive end to limit the end of output series

*Example:*

MSFT.percentChange(1,Enum.MONTHS).bound(-.2,.2).percentReturnToLevel() //an artificial time series of prices that has Winsorized returns

None -> String

*Description:*

Prints the object's string representation to the console and returns the printed string.

*Parameters:*

- Object: Object to convert to print.

*Example:*

`print("Hello World!")`

TimeSeries -> TimeSeries

*Description:*

Samples a time series at different frequency. The sampling operations works as follows. For every pair of adjacent dates, d1 and d2, in the Date Set: (1) Find all points in the input time series that lie in the range (d1, d2], i.e., strictly after the first day, and up-to-and-including the second day. (2) Use the aggregator (LAST, if none is specified) to aggregate the points from step 1. (3) Add the value from step 2 to the output time series, timestampedat d2. Note: If no value exists in the input time series between two adjacent days in the Date Set, there will be no corresponding point in the output time series.

*Parameters:*

- SamplingDateSet: The Date Set defining the points on which to sample the input time series
- Aggregator: The aggregate type defines how the system combines values

*Example:*

CN.pop().sample(DateSet("Fridays")) //China's population sampled every Friday

For more information, see Working with Time Series Data#Clipping Time Series.

TimeSeries -> TimeSeries

*Description:*

Depending on the sign of the number(s), returns -1 or +1 for a single number or the numbers in a time series.

*Parameters:*

None

*Example:*

```
JP.pop.percentChange().sign()
//changes in Japan's population over time
```

TimeSeries -> TimeSeries

*Description:*

Returns values for days specified in a date set. The date set can contain non-contiguous dates, dates in a range, or a recurring series of dates like all the dates in January of every year for which values are available.

*Parameters:*

- Periods to use: Set the date range.

*Example:*

CA.gdp.slice(DateSet("Past Month"))

For more information, see Working with Time Series Data#Clipping Time Series.

TimeSeries -> TimeSeries

*Description:*

Aggregates two time series by adding points from the specified time series to the input time series based on aggregating rules (Append, Prepend, Merge, or Both). If both time series have a point at a specific time, the input time series takes priority (the other point is thrown out). The frequency of the specified time series is rasterized to that of the input time series.

*Parameters:*

- TimeSeries: Which time series to stitch on.
- Stitching method: Aggregation method.

*Example:*

GM.ma(50).stitch(GM.ma(25),Enum.PREPEND)

For more information, see Working with Time Series Data#Clipping Time Series.

Date -> DateSet

*Description:*

Returns a Date Set representing the range between the input Date and the parameter Date. The Date Set will be inclusive of the input Date and the parameter Date at daily or greater frequency. It thus represents the range [input, parameter] at daily or greater, and [input, parameter) at intraday.

*Parameters:*

- Date: The end Date for the Date Set. This Date is inclusive at daily or greater frequency, meaning it will be in the resulting Date Set.

*Example:*

'2009-01-01'.to('2010-01-01')

Object -> String

*Description:*

Evaluates to a concise but informative string representation.

*Parameters:*

None

*Example:*

US.toString()

Date -> DateSet

*Description:*

Returns a Date Set representing the range between the input Date and the parameter Date.

*Parameters:*

- Date: The end Date for the Date Set.
- Inclusive: Whether the end Date is inclusive.

*Example:*

'2009-01-01'.until('2010-01-01')

TimeSeries -> DateSet

*Description:*

Returns a DateSet made up of all the dates where the time series has a point.

*Parameters:*

- Frequency: Sets the Date Set frequency.

*Example:*

US.investment.validDates()

TimeSeries -> Number

*Description:*

Returns the value in a time series on the value-on date. Unlike valueOn(), value() does not allow you to select which date to use, but instead defaults to the application's specified valueOn date.

*Parameters:*

- Slice name: Specifies the nearest date behavior. Defaults to on or before logic. Other Enum options include,
`AFTER, BEFORE, ON_OR_AFTER, ON_OR_BEFORE`and`ON`

*Example:*

MSFT.volume().value()

TimeSeries -> Number

*Description:*

Returns the value of the time series on the specified date. If no value exists on the specified date, the metric can return a value by either looking forward or backward in time. In the examples, assume that IBM.eps() has values on 2009-09-30 and 2009-12-31.

*Parameters:*

- Date: The date to get the value in the time series.
- NearestDate: An enumeration that specifies whether to get the value on, before, or after the date. This defaults to on or before lookback logic.
- Num Units: The number of calendar periods to look forward or backwards.
- Frequency: The length of each calendar period specified in the num units parameter.

*Example:*

// Gets the first value after 12-30 which is at most 1 week after. US.pop().valueOn('2009-12-30', Enum.AFTER, 1, Enum.WEEKS) // Returns the first value after 09-30 which is at most 4 months after. US.pop().valueOn('2009-12-30', Enum.AFTER, 4, Enum.MONTHS) // Gets the first value after 12-30 which is at most 1 week before. US.pop().valueOn('2009-12-30', Enum.BEFORE, 1, Enum.WEEKS)

Need Help? Email us at © 2014 Palantir Technologies · Terms of Use · Privacy and Security Statement