These tables have example expressions that can be used as models when you are setting up expressions for calculated measure items.
Note: If you want to set up views that return YTD data, comparisons of current vs past periods, rolling N periods, previous N periods, etc., do so using regular measure items with time ranges. Examples are in Using Time Ranges vs. Time Hierarchies in Views. If you want to set up a calculated measure item that displays an image, see Display Images for Measure Items.
Type of Calculation & Function |
Example |
Achievement Percent Has a built-in divide by zero check to avoid divide by zero errors. |
#AchievementPercent([Measures].[Data1 (Actual Sales Sales Amount Q1 2014 to Q3 2014 )], [Measures].[Data2 (Budget Budget Amount Frozen Q1 2014 to Q3 2014)])
|
Divide with Zero Check Has a built-in divide by zero check to avoid divide by zero errors. |
#DivideWithZeroCheck([Measures].[Data1 (Daily Sales Amount Wk 38 2014 to Wk 38 2014)], [Measures].[Data2 (Daily Sales Units Wk 38 2014 to Wk 38 2014)])
|
Percent of Change Has a built-in divide by zero check to avoid divide by zero errors. |
#PercentOfChange([Measures].[Data1 (Actual Sales Amount Q1 2013 to Q3 2013)], [Measures].[Data2 (Actual Sales Sales Amount Q1 2012 to Q3 2012)])
|
Percent Of Total |
#PercentOfTotal([Measures].[Data1 (Daily Sales Amount Jan 2014 to Sep 2014)])
|
Cumulative Percent Of Total and ABC Cumulative Percent Of Total |
#CumulativePercentOfTotal([Measures].[Data1 (Daily Sales Amount Jan 2014 to Sep 2014)])
and #ABCCumulativePercent([Measures].[Data1 (Daily Sales Amount Jan 2014 to Sep 2014)],".65;.25")
|
Cumulative Total and ABC Cumulative Total |
#CumulativeTotal([Measures].[Data2 (Budgeted Units Jan 14 to Sep 14)])
and #ABCCumulative([Measures].[Data2 (Budgeted Units Jan 14 to Sep 14)],"75000000.00;35000000.00;10000000.00")
|
Type of Calculation & Function |
Example Expression |
Average Uses Average numeric function. |
Avg({[Time].[Year Months].[Year].members},[Measures].[Actual Sales Sales Units])
and Avg({[Time].[Year Months].[Year].[2013], [Time].[Year Months].[Year].[2014]},[Measures].[Actual Sales Sales Units])
|
Difference |
[Measures].[Data22 (Act Gross Margin After Rebate)]-[Measures].[Data21 (Std Gross Margin After Rebate)] Returns difference between the Act Gross Margin After Rebate and Std Gross Margin After Rebate measure items (their captions and the measure item names Data22 and Data21 are part of the MDX syntax in the expression). |
Extended List Price Uses attribute relationship. |
IIF([Product].[Product].CurrentMember.Level.Name="Product",[Product].[Product].Properties("Prod Current List Price") * [Measures].[Data5 (Daily Sales Units Jan 2014 to Sep 2014)], null)
Here is the view when the Product level is visible. The calculation is performed. Here is the view after it has been rearranged. Ship-to Territory is now visible and Product is no longer visible. Null values are returned. |
Number of Products Sold and Total Number of Products Uses Count numeric function and CrossJoin function. |
Count(CrossJoin({[UPC Global Number].[UPC Global Number].[UPC Global Number].members},{[Measures].[Data2 (Sales Amount Q3 2014 to Q3 2014)]}),EXCLUDEEMPTY) and Count(CrossJoin({[UPC Global Number].[UPC Global Number].[UPC Global Number].members},{[Measures].[Data2 (Sales Amount Q3 2014 to Q3 2014)]}),INCLUDEEMPTY)
|
Profit (Sales after Costs) and Sales after Returns Uses Absolute value of a measure item. |
[Measures].[Data2 (Actual Sales Sales Amount)]-[Measures].[Data1 (Actual Sales Ext Standard Cost)] and [Measures].[Data2 (Actual Sales Sales Amount)]-abs([Measures].[Data4 (Actual Sales Sales Return Amount)])
|
Return Text Value if Condition is Met Uses IIF function to check for conditions and determine which results to return. |
IIF([Measures].[Data22 (Actual Sales Sales Units Jan to Dec)]>[Measures].[Data2 (Budget Budget Units Frozen Jan to Dec)],"y",null)
|
Standard Cost Uses Val function and attribute relationship. IIF function checks for presence of the level to which attribute relationship belongs. |
IIF([Product].[Product].CurrentMember.Level.Name="Product",Val([Product].[Product].Properties("Prod Std Cost Last Year"))*[Measures].[Data2 (Actual Sales Units)], null)
Here is the view when the Product level is visible. The calculation is performed. Here is the view when Ship-to Market has been drilled up to and Product is no longer visible. Null values are returned. |
Top N Total and Bottom N Total Use Sum function. |
Sum({TopCount([RepBroker].[RepBroker].[RepBroker].members, 4, [Measures].[Data2 (Daily Sales Units Current Yr Month)])}, [Measures].[Data2 (Daily Sales Units Current Yr Month)]) and Sum({BottomCount([RepBroker].[RepBroker].[RepBroker].members, 4, [Measures].[Data2 (Daily Sales Units Current Yr Month)])}, [Measures].[Data2 (Daily Sales Units Current Yr Month)])
|
Variance Percentage
|
Use the Percent of Change function when you want to include a variance percentage calculation in your view. That function is a Stratum.Viewer function that automatically includes a divide by zero check in the calculation to avoid divide by zero errors. See the first table in this topic for an example. |
Days Until Expiration Uses the Date Difference function in combination with the Today date function and an attribute relationship. |
DateDiff("d", Now(), [Lot].[Lot].Properties("Lot Expiration Date"))
Notes: Results returned with negative numbers mean the expiration date has already been passed and it occurred the specified number of days ago. This example happens to calculate the "days" until expiration; therefore, it uses the parameter of "d" in the Date Difference function. Here are other parameters that can be used for calculations that involve other intervals of time: yyyy for year, q for quarter, m for month, y for day of year, d for day, w for weekday, ww for week, h for hour, m for minute, and s for second. |