Defines a single measure shown in a dashboard, report or reward, combining a reference to a MetricType (which knows how to calculate the value) with the entity, date range, caching and display settings for that measure. Instances are typically constructed with newMetricBuilder or QueryManager.newMetricBuilder and are persisted to XML under the element name "metric". QueryService.calcMetric resolves the entity from entitySelection, applies dateMode and any cacheConfig, and delegates the actual calculation to the MetricType named by metricTypeId.
Group: Queries
Implements: PortableId
Properties
| Property | Returns | Description |
|---|---|---|
| appliesTo | Set<String> | Identifiers for what this metric is used for, for example "reward-123", allowing a consumer to find metrics associated with a particular object. |
| cacheConfig | MetricCacheConfig | The caching and pre-calculation configuration for this metric, if it was configured with a durationUnit. |
| dateMode | DateMode | How the date range for this metric's calculation is derived, such as from the common date selector, a constant range, or relative to the previous period, year or quarter. |
| decimals | int | The number of decimal places the calculated value should be displayed with. |
| description | String | The descriptive text for this metric, delegated to the description provided by its MetricType. This looks up the metric type by metricTypeId on every call, so it is not a simple field accessor. |
| endDate | Date | Optional. If provided this is used instead of standard query dates |
| entityAccount | boolean | Whether this metric's entity selection is the whole account. |
| entityCurrentOrg | boolean | Whether this metric's entity selection is the current org. |
| entityCurrentProfile | boolean | Whether this metric's entity selection is the current profile. |
| entityName | String | The name of the entity this metric applies to, used with the specifiedProfile and specifiedOrg entity selections. |
| entitySelection | EntitySelection | Which entity this metric is calculated against, such as the whole account, the current profile or org, or a specifically named profile or org. |
| entitySpecifiedOrg | boolean | Whether this metric's entity selection is a specifically named org, given by entityName. |
| entitySpecifiedProfile | boolean | Whether this metric's entity selection is a specifically named profile, given by entityName. |
| icon | String | The icon shown alongside this metric, typically a font icon class name such as "fa-users". |
| id | String | The unique identifier of this metric, used to reference it from other configuration and as its portable id. |
| metricTypeId | String | The id of the MetricType that calculates this metric's value. |
| notes | String | Free text notes about this metric. |
| params | Map<String,String> | Additional parameters passed through to the metric type's calculation function. |
| startDate | Date | Optional. If provided this is used instead of standard query dates |
| title | String | The display title of this metric. |
| unit | String | The unit label shown alongside this metric's value, such as "%" or "$". |
| unitPosition | UnitPosition | Whether the unit label is displayed before or after the value. |
Methods
portableId() · getId() · getTitle() · getIcon() · getDecimals() · getDateMode() · getStartDate() · getEndDate() · getMetricTypeId() · getParams() · getNotes() · getEntityName() · getEntitySelection() · getAppliesTo() · isEntityAccount() · isEntityCurrentProfile() · isEntitySpecifiedProfile() · isEntitySpecifiedOrg() · isEntityCurrentOrg() · getDescription() · param(String name) · getUnit() · getUnitPosition() · getCacheConfig()
portableId()
Returns: String
The portable identifier for this metric, which is the same as getId.
getId()
Returns: String
The unique identifier of this metric, used to reference it from other configuration and as its portable id.
getTitle()
Returns: String
The display title of this metric.
getIcon()
Returns: String
The icon shown alongside this metric, typically a font icon class name such as "fa-users".
getDecimals()
Returns: int
The number of decimal places the calculated value should be displayed with.
getDateMode()
Returns: DateMode
How the date range for this metric's calculation is derived, such as from the common date selector, a constant range, or relative to the previous period, year or quarter.
getStartDate()
Returns: Date
Optional. If provided this is used instead of standard query dates
getEndDate()
Returns: Date
Optional. If provided this is used instead of standard query dates
getMetricTypeId()
Returns: String
The id of the MetricType that calculates this metric's value.
getParams()
Returns: Map<String,String>
Additional parameters passed through to the metric type's calculation function.
getNotes()
Returns: String
Free text notes about this metric.
getEntityName()
Returns: String
The name of the entity this metric applies to, used with the specifiedProfile and specifiedOrg entity selections.
getEntitySelection()
Returns: EntitySelection
Which entity this metric is calculated against, such as the whole account, the current profile or org, or a specifically named profile or org.
getAppliesTo()
Returns: Set<String>
Identifiers for what this metric is used for, for example "reward-123", allowing a consumer to find metrics associated with a particular object.
isEntityAccount()
Returns: boolean
Whether this metric's entity selection is the whole account.
isEntityCurrentProfile()
Returns: boolean
Whether this metric's entity selection is the current profile.
isEntitySpecifiedProfile()
Returns: boolean
Whether this metric's entity selection is a specifically named profile, given by entityName.
isEntitySpecifiedOrg()
Returns: boolean
Whether this metric's entity selection is a specifically named org, given by entityName.
isEntityCurrentOrg()
Returns: boolean
Whether this metric's entity selection is the current org.
getDescription()
Returns: String
The descriptive text for this metric, delegated to the description provided by its MetricType. This looks up the metric type by metricTypeId on every call, so it is not a simple field accessor.
param(String name)
Returns: String
Looks up a single named parameter value from this metric's params map.
| Parameter | Description |
|---|---|
name | the parameter name |
getUnit()
Returns: String
The unit label shown alongside this metric's value, such as "%" or "$".
getUnitPosition()
Returns: UnitPosition
Whether the unit label is displayed before or after the value.
getCacheConfig()
Returns: MetricCacheConfig
The caching and pre-calculation configuration for this metric, if it was configured with a durationUnit.