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(Value_Expression)
Arguments
Value_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 the context changes in columns.
- Function Cache()