ConstantValue
Calculates the value only once per report execution and stores it as one value per report in the cache. It can be useful when one value should be used in several calculations in the same report.
Syntax
ConstantValue(Expression)
Arguments
Expression | MDX expression that typically returns a measure, a tuple, or a string. |
---|
Examples
A report has a measure that should calculate one common value and then reuse it for different other formulas. For example, the report calculates a start date of the report and then uses this start date for different cases - to show periods, calculate predictions, etc.
The formula example below calculates the start date of the report based on the individual version start date or the first date when an issue was moved to in progress. This calculation will be applied only once (first context) per report execution. It should be used in other calculations to get value out of caching those results.
ConstantValue(
Case when
Not isempty([Fix Version].CurrentHierarchyMember.get('Start date'))
Then
-- Selected fix versions has Start Date, this date is used as Start Date
[Fix Version].CurrentHierarchyMember.getDate('Start date')
Else
-- the first date when an issue in version moved to any in progress status
DateParse(([Measures].[Transition to status first date],
[Transition Status.Category].[In Progress],
[Time].CurrentHierarchy.Defaultmember))
End)
See also
Function ConstantColumnValue() works similarly. It should be used if context changes in columns.
Function Cache()