All Example Expressions in Viewer Help

Click to see example expressions for the type of item you are working with in Stratum.Viewer.

Axis Filters

The following examples show an axis filter that uses just measure items and an axis filter that uses a measure item and an attribute relationship. A table containing more example expressions follows these two examples.

Example 1 - Two Measure Items in Axis Filter

This axis filter on columns returns columns where Avg Selling Price is greater than or equal to $75.00 and Profit is greater than $50,000.

[Measures].[Data6 (Avg Selling Price)]>=75 AND [Measures].[Data8 (Profit)]>50000

Here is the Expression window for the filter.

Example 2 - Measure Item and Attribute Relationship in Axis Filter

This axis filter on rows returns rows where the Product sales for the current period of the current year are greater than $150,000 and the Prod ABC Classification for the Product is A. The first part of the expression contains the sales measure item criteria, and the second part contains the attribute relationship criteria.

The IIF statement in the second part checks that the level for the attribute relationship referenced in the expression is visible in rows. In this case, the level is visible so Stratum.Viewer considers that filter condition when executing the filter. If the level had not been visible, the condition would have been ignored while executing the filter.

[Measures].[Data2 (Current Period This Year)]>150000 and IIF([Product].[Product].CurrentMember.Level.Name="Product",[Product].[Product].Properties("Prod ABC Classification")="A",1)

Note: The portion of the above MDX that checks for the level visibility references the name of the dimension and hierarchy for the level -- in this case [Product].[Product]. The hierarchy name is needed in cases where there are multiple hierarchies within the same dimension.

This is the Expression window for the filter.

Here's what the view would look like if you were to drill up to RepBroker. Only the [Measures].[Data2 (Current Period This Year)]>150000 part of the axis filter expression is executed since Product is no longer visible.

More Example Expressions

Desired Results...

Example Axis Filter

For all levels, Average Selling Price is >= 75 and Profit > 50,000.

[Measures].[Data6 (Avg Selling Price)]>=75 And [Measures].[Data8 (Profit)]>50000

 

When at Product level, will return rows where Prod ABC Classification = “A” AND Actual Sales Sales Units Jan 2014 to Sep 2014 is > 150,000. When at any other level - Actual Sales Sales Units Jan 2014 to Sep 2014 is > 150,000.

[Measures].[Data1 (Actual Sales Sales Units Jan 2014 to Sep 2014)]>150000 and IIF([Product].[Product].CurrentMember.Level.Name="Product",[Product].[Product].Properties("Prod ABC Classification")="A",1)

Only for the Product level, return rows where Prod ABC Classification = “A” AND Actual Sales Sales Units Jan 2014 to Sep 2014 is > 150,000. When at any other level – No filter applied.

IIF([Product].[Product].CurrentMember.Level.Name="Product" , IIF ([Product].[Product].Properties("Prod ABC Classification")="A" AND [Measures].[Data1 (Actual Sales Sales Units Jan 2014 to Sep 2014)]>150000, 1,0) , 1)

When at Product level, will return rows where Actual Sales Sales Units Jan 2014 to Sep 2014 is > 150,000.  When at any other level - Actual Sales Sales Units Jan 2014 to Sep 2014 is > 10,000,000.

IIF([Product].[Product].CurrentMember.Level.Name="Product" , IIF ([Measures].[Data1 (Actual Sales Sales Units Jan 2014 to Sep 2014)]>150000, 1,0) , [Measures].[Data1 (Actual Sales Sales Units Jan 2014 to Sep 2014)] > 10000000)

When at Product level, will return rows where Prod ABC Classification = “A” AND Actual Sales Sales Units Jan 2014 to Sep 2014 is > 150,000.  When at any other level - Actual Sales Sales Units Jan 2014 to Sep 2014 is > 10,000,000.

IIF([Product].[Product].CurrentMember.Level.Name="Product" , IIF ([Product].[Product].Properties("Prod ABC Classification")="A" AND [Measures].[Data1 (Actual Sales Sales Units Jan 2014 to Sep 2014)]>150000, 1,0) , [Measures].[Data1 (Actual Sales Sales Units Jan 2014 to Sep 2014)] > 10000000)

Calculated Measure Items

These tables have examples that can be used as models when you are setting up 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 Time Ranges vs. Time Hierarchies for YTD, Trending, and Other Time Analysis. If you want to set up a calculated measure item that displays an image, see Display Images for Measure Items.

Calculations with Stratum.Viewer Functions

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)])

  • Returns the achievement percentage between two measure items -- in this case, the percent of sales achieved in comparison to the budgeted sales.

  • The expression for this function is Measure Item 1 / Measure Item 2 with a divide by zero check. The divide by zero check will return null if Measure item 2, the divisor, is zero or null.

  • The expression syntax includes the names (Data1 and Data2) and captions of the specified measure items.

  • Recommendations: select a percentage Format String and set Total property to None.

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)])

  • Divides two numbers with a divide by zero check.
  • The expression for this function is Measure Item 1 / Measure Item 2 with a divide by zero check. The divide by zero check will return null if Numeric Expression 2, the divisor, is zero or null.
  • The expression syntax includes the names (Data1 and Data2) and captions of the specified measure items.

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)])

  • Returns the percent of change, also known as the variance percentage, between two measure items or expressions -- in this case, the change between YTD sales for two different years.

  • The expression for this function is (Measure Item 1 - Measure Item 2) / Measure Item 2 with a divide by zero check. The divide by zero check will return null if Measure item 2, the divisor, is zero or null.

  • The expression syntax includes the names (Data1 and Data2) and captions of the specified measure items.

  • Recommendations: select a percentage Format String and set Total property to None.

Percent Of Total

#PercentOfTotal([Measures].[Data1 (Actual Sales Amount Wk 1 2017 to Wk 37 2017)])

  • Returns percent of total for the designated measure item, in this case Actual Sales Amount Wk 1 2017 to Wk 37 2017 (this caption and the measure item name of Data1 are part of the MDX syntax in the expression).

  • Recommendations: select a percentage Format String.

Percent Of Subtotal

#PercentOfSubtotal([Measures].[Data1 (Actual Sales Amount Wk 1 2017 to Wk 37 2017)])

  • Calculates how much a measure item value contributes to the subtotal. This example returns percent of subtotal for the Actual Sales Amount Wk 1 2017 to Wk 37 2017 measure item (the measure item’s caption and its name of Data1 are part of the MDX syntax in the expression).

  • Recommendations select a percentage Format String.

Cumulative Percent Of Total

and

ABC Cumulative Percent Of Total

#CumulativePercentOfTotal([Measures].[Data1 (Daily Sales Amount Jan 2014 to Sep 2014)])

  • Returns cumulative percent of total for the designated measure item, in this case Daily Sales Amount Jan 2014 to Sep 2014 (this caption and the measure item name Data1 are part of the MDX syntax in the expression).

  • Recommendations: select a percentage Format String and set Total property to None.

and

#ABCCumulativePercent([Measures].[Data1 (Daily Sales Amount Jan 2014 to Sep 2014)],".65;.25")

  • Assigns specified ranking values to results of the cumulative percent of total calculation, based on ranges specified in the expression. This expression assigns the following ranks: A for values >= 65%. B for values < 65% and >= 25%, and C for values < 25%.

  • Recommendations: leave Format String set to None and set Total property to None.

Cumulative Total

and

ABC Cumulative Total

 #CumulativeTotal([Measures].[Data2 (Budgeted Units Jan 14 to Sep 14)])

  • Returns cumulative total for the designated measure item, in this case Budgeted Units Jan 14 to Sep 14 (this caption and the measure item name Data2 are part of the MDX syntax in the expression).

  • Recommendations: set Format String to the same Format String for the measure item referenced in the expression and set Total property to None.

and

#ABCCumulative([Measures].[Data2 (Budgeted Units Jan 14 to Sep 14)],"75000000.00;35000000.00;10000000.00")

  • Assigns specified ranking values to results of the cumulative total calculation, based on ranges specified in the expression. This expression assigns the following ranks: A for values >= 75,000,000; B for values < 75,000,000 and >= 35,0000,000; C for values < 35,000,000 and >= 10,000,000; and D for values < 10,000,000.

  • Recommendations: leave Format set to None and set Total property to None.

Other Types of Calculations

Type of Calculation & Function

Example Expression

Average

Uses Average numeric function.

Avg({[Measures].[Data1 (Sales Units Jan 2014 to Dec 2014)], [Measures].[Data2 (Sales Units Jan 2013 to Dec 2013)]})

·        Returns average sales units for 2013 and 2014. The expression syntax includes the names (Data1 and Data2) and captions of two regular measure items that are part of the view.

·         Recommendation: set Type to Distinct Calculated.

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)

  • If the Product level is visible, then the following calculation is performed: [Product].[Product].Properties("Prod Current List Price") * [Measures].[Data5 (Daily Sales Units Jan 2014 to Sep 2014)]. This returns the extended list price by multiplying the Prod Current List Price attribute relationship from the Product level by the Daily Sales Units Jan 2014 to Sep 2014 measure. If the Product level is not visible in the view, the calculation will not be performed and a null value (empty cell) will be returned.

  • The IIF and [Product].[Product].CurrentMember.Level.Name="Product" syntax check for the visibility of the level to which the attribute relationship belongs. The syntax for the measure item used in the expression includes its name (Data5) and caption. The name of the Product level and its hierarchy are included in the syntax.

  • Recommendation: select a monetary Format String.

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)

  • The first calculation counts the number of UPC's that have sales. The EXCLUDEEMPTY text is the part of the expression that will exclude UPC members without any sales from the count.

  • The second calculation counts the total number of UPC's that exist including those with and without sales. The INCLUDEEMPTY text is the part of the expression that will include UPC members without any sales in the count.

  • The MDX for the UPC Global Number level includes the level name and names of its dimension and hierarchy. The level is analyzed against sales amount values for the third quarter 2014, and the syntax for that part of the expression includes the measure item name (Data2) and caption.

  • Recommendation: leave the Format String set to None and set Total property to None.

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)])

  • The first expression returns the profit, the total sales after costs. The syntax for the two measure items used in the calculation includes their captions and names (Data2 and Data1).

  • The second expression returns the sales after returns. The syntax for the two measure items used in the calculation includes their names (Data2 and Data4) and captions. That part of the expression also uses the Abs function to use the absolute value of returns in the calculation.

Segment the Total Sales For a Level by Specific Members of a Different Level (see more detail)

 

Uses the SUM function, Members, and Tuples

This type of calculation lets you segment totals for levels in your view by members of other levels. For example, look at a Ship-To Market and Product Category sales by specific distribution channels. The following gives you the total sales within each Market/Category for only two specific distribution channels and ignores values for all other channels.

IIF([Measures].[Data1 (Total Sales Jan CY to Sep CY)]<>0,SUM({[Distribution Channel].[Distribution Channel].[Distribution Channel].[INB],[Distribution Channel].[Distribution Channel].[Distribution Channel].[DIR]},[Measures].[Data1 (Total Sales Jan CY to Sep CY)]),null)

  • Two tuples are joined together by the SUM function in the expression, and that tells Viewer to retrieve sales values for those two specific distribution channels. This example sums the total sales for Indirect - Broker (INB) and Direct Sales (DIR) distribution channels.

  • The IIF function in the expression checks that sales values exist before performing the calculation. The calculation is performed only if values exist, otherwise a null value (empty cell in your view grid) is returned by the calculation.

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)

  • Uses the IIF function to set up an If/Then/Else scenario. If the specified condition is true, then the first specified value will be returned. Otherwise (else), a null value will be returned. In this case, the condition checked for is whether or not Actual Sales Sales Units are greater than Budget Budget Units Frozen. The calculation returns a "y" (for Yes) if the condition is true. If the condition is not true, the calculation returns a null value (empty cell).

  • The syntax for the two measure items in both examples includes their names (Data22 and Data2) and captions.

  • Recommendations: leave Format String set to None. You can use a variety of values for the returned text, such as a letter or word, based on what best suits your view needs. In this case, null is recommended as the second (Else) value to prevent otherwise empty rows or columns from displaying. For example, if a row is hidden by relationship and empty filter because it has no sales or budget data, it would display if you set the second value in the expression to a 0 or "n" because those results would be considered a value by the relationship and empty filter. Using null as we did keeps results in an empty cell for such rows and therefore the rows will remain hidden. See also Using Relationship and Empty Filters.

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)

  • If the Product level is visible in the view, then the following calculation is performed:
    Val([Product].[Product].Properties("Prod Std Cost Last Year"))*[Measures].[Data2 (Actual Sales Units)]. This returns the standard cost for last year and uses the Prod Std Cost Last Year attribute relationship multiplied by the Actual Sales Units to determine the results. If the Product level is not visible in the view, the calculation will not be performed and a null value (empty cell) will be returned.

  • The IIF and [Product].[Product].CurrentMember.Level.Name="Product" syntax check for the visibility of the level to which the attribute relationship belongs. The syntax for the measure item used in the expression includes its name (Data2) and caption.

  • Recommendation: select a monetary Format String.

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)])

  • The first calculation returns the total sales of the four RepBrokers with the highest sales. The portion of the expression enclosed in curly brackets { } and beginning with TopCount is what tells Stratum.Viewer to look for the four RepBroker members with the highest values for the specified measure item of Daily Sales Units Current Yr Month. The sum part of the expression is what totals the four values. The expression syntax includes the name of the RepBroker level, hierarchy, and dimension and includes the name (Data2) and caption of the measure item.

  • The second calculation returns the total sales of the four RepBrokers with the lowest sales. The calculation is set up the same as the first calculation except it uses the BottomCount function.

  • Recommendation: set Format String to the same Format String for the measure item referenced in the expression and set Total property to None.

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"))

  • Returns the days until items expire, in this case, Lots. This calculation was built by selecting the Date Difference function, specifying "d" to calculate the difference in days, then selecting the Today function (which returned the Now() syntax), and finally selecting the Lot Expiration Date attribute relationship from the Lot level. The Date Difference and Today functions are in the VBA folder of the Expression window.

  • The current date in this case was August 15, 2014. The difference between that date and the Lot Expiration Date gives us the results in the Days Until Expiration date column in the example that follows.

  • Recommendations: leave the Format String set to None and set the Total property to None.

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.

Captions for Measure Items

Examples of measure item captions that use different combinations of variables and static text are shown below. Examples are shown for all types of measure items -- regular with time ranges, regular without time ranges, and calculated. Captions can include a combination of the following elements or just one of these elements, whatever your preference:

Measure Items with Time Ranges

Here are the properties for a measure item with a time range. The measure item is based on the Daily Sales Daily Sales Amount measure from the Daily Sales category.

Here are some examples of caption expressions that were set up for the measure item and what each executed caption looked like in the view. In these examples, the current year is 2014 and the current month is September. The time elements in the evaluated captions reflect that current state of the data. Variables are the parts of the expressions that have brackets [ ] around them.

Builds Caption with...

Example Expression & Caption

Variables for measure, short description of periods, and short format for year (separated by spaces and static text)

Expression

[Measure] [From Period Short Desc] [From Year YY] to [To Period Short Desc] [To Year YY]

Caption in View

Variables for measure, long description of periods, and long format for years (separated by spaces and static text)

Expression

[Measure] [From Period Long Desc] [From Year YYYY] to [To Period Long Desc] [To Year YYYY]

Caption in View

Variable for category and measures (separated by spaces and static text)

Expression

[Category] - YTD [Measure]

Caption in View

Static text, line breaks, and variable for measure

Expression

Current YTD
Months
[Measure]

Caption in View

Measure Items without Time Ranges

Here are the properties for a measure item without time ranges. This measure item also is based on the Daily Sales Daily Sales Amount measure from the Daily Sales category.

Next are some examples of caption expressions that were set up for the measure item and what each executed caption looked like in the view. Variables are the parts of the expressions that have brackets [ ] around them.

Builds Caption with...

Example Expression & Caption

Variable for measure

Expression

[Measure]

Caption in View

Variable for category and static text

Expression

[Category] Amount $

Caption in View

Variable for category, line break, and static text

Expression

[Category]
Amount $

Caption in View

Calculated Measure Items

Here is an expression for a calculated measure item that uses two other measure items in a view to perform its calculation. In the examples that follow, caption variables from a sales amount and budget amount measure item in the view will be used to generate the caption for the calculated measure item.

Here is the view before the caption for the calculated measure item is customized. The caption is currently the default, which is the name of the calculated measure item – in this case Data3.

Next are two examples of caption expressions that were set up for the measure item and what each evaluated caption looked like in the view. Both examples that follow include static text and the captions of the sales amount and budget amount measure items that comprise the calculation. The caption for the calculated measure item will reflect the current period details from the sale amount and budget amount measure items. That caption will automatically adjust as the time period and data used in the calculation changes. The first example does not use line breaks in the caption expression. The second example includes line breaks.

Builds Caption with...

Example Expression & Caption

Static text, ‘Caption’ variables from two other measure items, without line break

Expression

Caption in View

Static text, ‘Caption’ variables from two other measure items, with line breaks

Expression

Caption in View

Next is the same calculated measure item with a conditional format applied to it. The conditional format is named Track Below 10 million and it displays a yellow arrow when the variance is below $10,000,000. The next example shows the grid after the caption expression was edited to include the Conditional Format Name variable in the expression.

Builds Caption with...

Example Expression & Caption

Variable for conditional format name

Expression

Caption in View

Displaying Images for Measure Items

Example 1

This view displays an image for each product. The calculated measure item “Product Image” defines the location and file name of the product images.

The Product Image measure item is defined as follows:

Expression – In this example, the product images reside in a subfolder of the Stratum.Viewer Images folder called “Silvon Custom/Product Images”. The first part of the expression determines the location of the product images and the remainder dynamically determines the file name.

"Images\Silvon Custom\Product Images\" + [Product].[Product].currentmember.name + ".png"

Value – Set to No.

Image – Set to Yes (required to display the image defined by the expression).

Total – Set to None.

Example 2

The example that follows shows a view containing images with hyperlinks that will take the user to MapQuest and Google using information from each Customer Sold-To attribute relationships. A pop-up label displays additional information for the user.

The Map It! measure item was defined as follows:

Expression – In this example, the image resides in a subfolder of the Stratum.Viewer Images folder called “Silvon Custom”. The full expression defines the relative path to the image:

"Images/Silvon Custom/Map.jpg"

Value – Set to No.

Image – Set to Yes (required to display the image defined by the expression).

Total – Set to None.

Pop-up Label Expression   Here’s the expression for the pop-up label:

“Click here to go to MapQuest”

Hyperlink – Here’s the expression used for the Map It! hyperlink:

"http://www.mapquest.com/maps/map.adp?&city=" + [Customer Sold-To].[Customer Sold-To].CurrentMember.Properties("SldTo City") + "&state=" + [Customer Sold-To].[Customer Sold-To].CurrentMember.Properties("SldTo Province State") + "&zipcode=" + [Customer Sold-To].[Customer Sold-To].CurrentMember.Properties("SldTo Postal Code") + "&country=US&cid=lfmaplink"

The Google It! measure item was defined as follows:

Expression – In this example, the image resides in a subfolder of the Stratum.Viewer Images folder called “Silvon Custom”. The full expression defines the relative path to the image:

"Images/Silvon Custom/google.jpg"

Value – Set to No.

Image – Set to Yes (required to display the image defined by the expression).

Total – Set to None.

Pop-up Label Expression Here’s the expression for the pop-up label:

“Click here to go to Google”

Hyperlink – Here’s the expression used for the Google It! hyperlink:

"http://www.google.com/search?hl=en&q=" + [Customer Sold-To].[Customer Sold-To].CurrentMember.Properties("SldTo Long Description")

Dynamic User Lists

These tables have example expressions that can be used as models when you are setting up expressions for dynamic user lists.

Note: These same types of expressions can be used when creating expression filters on levels in views. See Example Expressions for Filtering Levels.

Members in Expression

For each type of user list expression that follows, a specific example for the Product level is provided followed by the generic MDX format for that type of user list.

Returns Members that are...

Example Expression and MDX

Equal to X

[Product].[Product].CurrentMember IS [Product].[Product].[Product].[954023]

Returns the Product member with a value equal to 954023

Generic MDX Format

[DimensionName].[HierarchyName].CurrentMember IS [DimensionName].[HierarchyName].[LevelName].[value]

Not equal to X

[Product].[Product].CurrentMember.Name <> "954023"

Returns Product members with values not equal to 954023

Generic MDX Format

[DimensionName].[HierarchyName].CurrentMember.Name <> "value"

Greater than X

[Product].[Product].CurrentMember.Name > "954023"

Returns Product members with values greater than 954023

Generic MDX Format

[DimensionName].[HierarchyName].CurrentMember.Name > "value"

Greater than or equal to  X

[Product].[Product].CurrentMember.Name >= "954023"

Returns Product members with values greater than or equal to 954023

Generic MDX Format

[DimensionName].[HierarchyName].CurrentMember.Name >= "value"

Less than X

 

[Product].[Product].CurrentMember.Name < "954023"

Returns Product members with values less than 954023

Generic MDX Format

[DimensionName].[HierarchyName].CurrentMember.Name < "value"

Less than or equal to X

[Product].[Product].CurrentMember.Name <= "954023"

Returns Product members with values less than or equal to 954023

Generic MDX Format

[DimensionName].[HierarchyName].CurrentMember.Name <= "value"

In the specified range

[Product].[Product].CurrentMember.Name >= "954023" AND [Product].[Product].CurrentMember.Name <= "954622"

Returns Product members with values greater than or equal to 954023 and less than or equal to 954622  

Generic MDX Format

[DimensionName].[HierarchyName].CurrentMember.Name >= "value" AND

[DimensionName].[HierarchyName].CurrentMember.Name <= "value"

Equal to X OR equal to Y

[Product].[Product].CurrentMember IS [Product].[Product].[Product].[954023] OR [Product].[Product].CurrentMember IS [Product].[Product].[Product].[954622]

Returns Product members with values equal to 954023 or 954622

Generic MDX Format

[DimensionName].[HierarchyName].CurrentMember IS [DimensionName].[HierarchyName].[LevelName].[value 1] OR [DimensionName].[HierarchyName].CurrentMember IS [DimensionName].[HierarchyName].[LevelName].[value 2]

Attribute Relationships in Expression

For each type of user list expression that follows, a specific example for the Customer ShipTo level is provided followed by the generic MDX format for that type of user list.

Return Members with
Attribute Relationships that...

Example Expression and MDX

Are equal to the specified text

[Customer Ship To].[Customer Ship To].CurrentMember.Properties("State") = "IL"

Returns Customer ShipTo members with State equal to “IL”

Generic MDX Format

[DimensionName].[HierarchyName].CurrentMember.Properties("AttributeRelationshipName") = "value"

Contain the specified text

(INSTR(1, [Customer ShipTo].[Customer ShipTo].CurrentMember.Properties("ShpTo

Postal Code"), "8121") <> 0)

Returns Customer ShipTo members with Postal Codes that contain the text “8121"  

Generic MDX Format

(INSTR(1, [DimensionName].[HierarchyName].CurrentMember.Properties("AttributeRelationshipName"), "value") <> 0)

Don't contain the specified text

(INSTR(1, [Customer ShipTo].[Customer ShipTo].CurrentMember.Properties("ShpTo

Postal Code"), "2") = 0)

Returns Customer ShipTo members with Postal Codes that don't contain the text “2”  

Generic MDX Format

(INSTR(1, [DimensionName].[HierarchyName].CurrentMember.Properties("AttributeRelationshipName"), "value") = 0

Begin with the specified text

LEFT([Customer ShipTo].[Customer ShipTo].CurrentMember.Properties("ShpTo Postal Code"), 3)  = "481"

Returns Customer ShipTo members with Postal Codes that start with the 3 characters “481”   

Generic MDX Format

LEFT([DimensionName].[HierarchyName].CurrentMember.Properties("AttributeRelationshipName"), #) = "value"

The # in the generic format is the length of the string of characters for the specified value text. For example, if the value was "4812" rather than "481" in the Customer ShipTo example, then the # would have been 4 rather than 3 in that expression.

Hyperlinks for Measure Items in Views

Example – Open a Website and Pass View Information to Website

Example 1

This example uses a URL only in the hyperlink expression. Clicking the hyperlink in the related view will access the Mapquest home page.

"http://www.mapquest.com"

Example 2 and 3

The next examples include view information in the hyperlink expression. In the first example, several attribute relationships for Customer Sold-To are used in the expression. The city, state, and postal code information derived from the current member are used as parameter values in the URL.

"http://www.mapquest.com/maps/map.adp?&city=" + [Customer Sold-To].[Customer Sold-To].CurrentMember.Properties("SldTo City") + "&state=" + [Customer Sold-To].[Customer Sold-To].CurrentMember.Properties("SldTo Province State") + "&zipcode=" + [Customer Sold-To].[Customer Sold-To].CurrentMember.Properties("SldTo Postal Code") + "&country=US&cid=lfmaplink"

The second example has syntax that first checks to see if a particular attribute relationship exists. If so, the hyperlink opens to Google and searches on that attribute relationship. The SldTo Long Description is the attribute relationship used in the expression.

Iif([Customer Sold-To].[Customer Sold-To].CurrentMember.Properties("SldTo Long Description")=null, null, "http://www.google.com/search?hl=en&q=" + [Customer Sold-To].[Customer Sold-To].CurrentMember.Properties("SldTo Long Description"))

Example – Run another View and Filter it with Member Information from Original View

Example 1

This example opens another view and runs it based on that view definition only. The Stratum.Viewer URL and ID for the view are used in the expression. See also Passing Parameters into Views via URL’s for additional parameters that can be used in these expressions.

“http://silvonxyz:60001/ViewWindow.aspx?ViewId=10391”

Here is a view containing the hyperlink.

Here is the other view, Revenue Trending by Customer, which will open and prompt you to choose a sales director for which you want to see view data. The prompting comes from parameters tied to a level in the View Filter of the view.

Example 2

The previous expression is then adjusted to pass sales director information from the original view to the other view. The hyperlink will open the view and filter it for the sales director associated with the measure item value that was clicked.

"http://silvonxyz:60001/ViewWindow.aspx?ViewId=10391&vp:SalesDirector="+[Sales Director].[Sales Director].CurrentMember.name+ ""

The hyperlink is clicked for the measure item value of sales director Steve Mentas.

The trending view opens and is filtered for that particular sales director. No prompting to choose a parameter occurs because the hyperlink determines the sales director to use in the filter.

Level Expression Filters

Expression filters that reference member values and attribute relationships were used to filter levels in the following examples. The levels referenced in the filters need to be visible in the view in order for the filters to impact the view.

Note: These same types of expressions can be used when creating dynamic user lists. For more example expressions, see Example Dynamic User List Expressions.

Single Member in Expression

This expression returns Customer Sold-To members with values greater than 150280. You can adjust the filter quickly to return different results by changing out the > symbol in the expression for other symbols (such as <) or by changing the "150280" in the expression to a different value.

[Customer Sold-To].[Customer Sold-To].CurrentMember.Name > "150280"

Multiple Members in Expression

This expression filter returns Customer Sold-To members in a range that is greater than or equal to 150280 and less than or equal to 150350.

[Customer Sold-To].[Customer Sold-To].CurrentMember.Name >= "150280" AND [Customer Sold-To].[Customer Sold-To].CurrentMember.Name <= "150350"

Attribute Relationships in Expression

This filter returns Product Category members that have the text 'fruit' in their PCat Long Description attribute relationship.

(INSTR(1, [Product Category].[Product Category].CurrentMember.Properties("PCat Long Description"), "Fruit") <> 0)

Pop-up Labels for Measure Items

Example – Static Text & View Information

This expression uses static text in combination with information from the view. The pop-up label will vary as you click on each Map It! measure item value based on corresponding Customer Sold-To member information.

"Click here to go to MapQuest for " + [Customer Sold-To].[Customer Sold-To].CurrentMember.Properties("SldTo Long Description")

Example – Static Text, Attribute Relationships, & Line Breaks

This example creates a pop-up label consisting of multiple lines of text to display descriptive information (attribute relationships) for a dimension in the view. Putting the attribute information in a pop-up label rather than in columns of the view saves some room.

Here’s the example expression. The text in quotes at the beginning of each line of the expression is static text. The next part in each line of the expression are Customer Sold-To attribute relationships.

“Address: " + [Customer Sold-To].[Customer Sold-To].Properties("SldTo Address Line 1") +

“City:        " + [Customer Sold-To].[Customer Sold-To].Properties("SldTo City") +

“Email:      " + [Customer Sold-To].[Customer Sold-To].Properties("SldTo Email Address") +

“Phone:     " + [Customer Sold-To].[Customer Sold-To].Properties("SldTo Phone Number")

Example – Measure Item Value Variable

This expression uses only the Measure Item Value variable.

#MeasureItem(“Value”)

Example – Static Text & Measure Item Variables

This expression uses static text in combination with the two Measure Item variables.

"The value of " + #MeasureItem("Caption") + " is " + #MeasureItem("Value")

Example – Static Text & Conditional Format Variables

This expression uses two of the Conditional Format variables separated by static text (a dash mark). The pop-up label is for a measure item that has a conditional format defined for it.

#ConditionalFormat("Name") + " - " + #ConditionalFormat("Description")

Example - Conditional Pop-up Label

This expression uses the IIf function to define a conditional expression. The label will display one of two statements depending on the conditions in the view grid. If Gross Margin Amount is less than $5,000, the first statement will display. If the margin is greater than $5,000, then the second statement will display.

IIf([Measures].[Data23 (Gross Margin Amount Jan 2014 to Sep 2014)] < 5000, "Product's margin is below the desired level. Place product on the monthly review list." , "Margin is within acceptable range. No action is needed.")

Example – Format Variable & Showing Values Behind a Calculation

This expression displays the value of a sales amount measure item followed by a division sign and the value of a sales units measure item. The VBA Format function is used to control the display format of the values in the pop-up label. The pop-up label is meant to show the values behind a calculated measure item’s results.

Format([Measures].[Data1 (Actual Sales Sales Amount Wk 38 2014 to Wk 38 2014)], "$#,##0.00;($#,##0.00)") + " / " + Format([Measures].[Data2 (Actual Sales Sales Units Wk 38 2014 to Wk 38 2014)], "#,###,##0")

Rolling "N" Period Based Views

These examples show how to create period based views that display rolling “N” periods. This is done by creating a level filter on a time hierarchy. The time range property for the view in both examples was set to No.

The first view is a rolling 12 weeks. It has rows comprised of the two levels from the Year Weeks time hierarchy. The Weeks level has a Rolling “12” filter on it that calculates the current week and prior 11 weeks. The filter returns Week 38 back through Week 27 in this example.

The expression for the level filter is:

COUNT(EXISTS([Time].[Year Weeks].CurrentMember,LASTPERIODS(12,EXISTS([Time].[Year Weeks].[Weeks].members,[Time].[Year Based Weeks Based].[Year Based].[Current Year].[Current Week]).Item(0))))

This expression uses the Year Based Weeks Based hierarchy to determine the Current Week, Current Year.

A simple change to the expression changes the view to a rolling 52 weeks. Change the 12 in the expression to 52. It will calculate the current week and prior 51 weeks.

COUNT(EXISTS([Time].[Year Weeks].CurrentMember,LASTPERIODS(52,EXISTS([Time].[Year Weeks].[Weeks].members,[Time].[Year Based Weeks Based].[Year Based].[Current Year].[Current Week]).Item(0))))

Here is the refreshed view after making that change. The filter returns Week 38 of 2014 through Week 39 of 2013.

If you want to see rolling periods in the future, use a negative number for the LASTPERIODS part of the expression. Here is the expression when the 52 is changed to -52. It will calculate the current week and next 51 weeks.

COUNT(EXISTS([Time].[Year Weeks].CurrentMember,LASTPERIODS(-52,EXISTS([Time].[Year Weeks].[Weeks].members,[Time].[Year Based Weeks Based].[Year Based].[Current Year].[Current Week]).Item(0))))

Here is the refreshed view after making that change. The filter returns Week 37 of 2015 through Week 38 of 2014. The future weeks for actual sales do not have data yet, so those cells are empty in the view. This type of filter would be useful in views that contain measures that have anticipated future data, such as budget or forecast measures.

Tuple-Based Calculations To Compare Current Year Vs. Last Year By Month

How do you compare this year vs. last year with months going down the side of a view and see the % of sales ratio? We get this question from time to time and it’s pretty easy to do. You could do this by describing 24 separate measures and then adding 12 more for a total of 36 that do the calculation between the last year and this year sales. But there is an easier way!

All you need to do is use time as a dimension (or in Stratum terms – set Time Range to No for its measure items) and create three measures that you want to repeat for every month (or week or any other time unit you choose).

Note: See Example 2 if you prefer to see Months across the top of a view in columns rather than down the side of a view in rows.

First – what do you mean – use time as a dimension? This allows you to have measures the automatically repeat for each time unit displayed. Simple example would be displaying sales and units for each month of a year or weeks or days.

To start – you have to set Time Range to No – this is a property of the Measures Items node in the View Explorer. Easy to do, just right click on Measures Items node in the view explorer window and select Properties – then change the Time Range to No (the default is Yes.

Once you've taken care of setting Time Range to No, you’ll want to include some Time in your view. So instead of having time controlled by column (as in a ‘typical’ view where you select the from and to time for each measure) we are going to have each measure repeated for every time unit we select. In this example, we have years and months. It's always recommended using Based time dimensions like Year Based Months Based since these based (or relative) time dimensions allow you to select Current Year (CY) and Last Year (LY) and will automatically switch years when the year changes. Same with the months – Current Month, Previous Month, etc.

Finally, you add some measures and set up a few calculations. The next two examples show this type of view and the specifics of the calculations that were set up.

Example 1

In this example, we used the Year Based Months Based dimension as a hidden dimension (used in our calculations) and the Months dimension. Then we added a Sales Amount measure item as a hidden measure item (used in our calculations), did a couple of calculations to get Current Year (CY) and Last Year (LY), and then we created a % calculation between CY and LY. If we were interested in just a single year – we could just show the Sales Amount measure in the view and we’d be done. But because we are going to select a couple of years, we need to create a simple calculation that filters our CY and LY sales. These calculations are called ‘Tuples’. The calculations are described after this image.

The calculation for Current Year looks like the following. The text preceeded by // is comment text that describes the calculation, and it gets ignored by Viewer. The [Time].[Year Based Weeks Based].[Year Based].[Current Year] is from the dimensions – this is filtering the Time dimension to show only the Current Year. The [Data1 (Sales Amount)] is the Sales Amount measure we want to see. Put a comma between them and add parens at the front and back and you’ve got yourself a Tuple.

// Tuple of Current year sales
([Time].[Year Based Months Based].[Year Based].[Current Year],[Measures].[Data1 (Sales Amount)])

Next, we created the same calculation for Last Year:
// Tuple of last years sales
([Time].[Year Based Months Based].[Year Based].[Last Year],[Measures].[Data1 (Sales Amount)])

Finally, we created a calculation to do the % calculation using a Stratum function – we used that function so that the divide by zero check is automatically handled. There are some helpful functions in the Stratum.Viewer Functions area of the calculation window, so check them out. You can add formatting and captions too as you set up your calculations using shortcuts in this window.

#AchievementPercent([Measures].[Data2 (Current Yr Sales)], [Measures].[Data3 (Last Yr Sales)])

Another helpful technique used in this example is to limit the months of data that get displayed so the view automatically only shows months thru the current month – that way, the future months without sales don’t show up (which is nice when comparing CY to LY particularly in a chart). You can do that using a filter on time such as a Named Set filter. Named sets are available for the Time dimensions like Months, Weeks and Days (without any Year associated with them). Named Sets are a list of time units (Months, Weeks, Days normally) that Stratum automatically updates to include months from the beginning of the year thru the current month. In this example, we right-clicked the Months dimension in the view, then selected Filter and Change Filter Type from the grid pop-up menu. Then we picked Named Set from the Select Filter Method window and picked a sales Named Set since our view is about sales. There is a Named Set for each type of monthly data (sales, budget, etc.).

Example 2

Here's another example using Tuple-based calculations. The layout of this view  is slightly different from prior example. We have Months going across the top on columns while the measure items we're comparing are down the side on rows. Notice too we're comparing Sales against Budget from different years. The calculations help us compare the percent of change between Actual Sales Units from one year to Budgeted Units for a different year. Expressions for the three calculations follow this image.

Here is the calculation used for Actual Sales Units for last year.

// Tuple of Last year sales units

([Time].[Year Based Months Based].[Year Based].[Last Year],[Measures].[Data1 (Sales Units)])

Here is the calculation used for Budgeted Units for the current year.

// Tuple of Current year budgeted sales
([Time].[Year Based Months Based].[Year Based].[Current Year],[Measures].[Data2 (Budgeted Units)])

Here is the calculation giving us the % of change between LY Actual Sales Units and CY Budgeted Units. We used the #PercentOfChange function from the Stratum.Viewer Functions folder for this calculation.

#PercentOfChange([Measures].[Data3 (LY Actual Sales Units)], [Measures].[Data4 (CY Budgeted Units)])