You are on page 1of 3

# Example: Showing average revenue per sale

## calculate the average number of items sold

calculate the difference between each number of items sold and the average, then square this
value

## Sum((([Quantity sold] - Average([Quantity sold] ForEach [Quarter])

In Report)*([Quantity sold] - Average([Quantity sold] ForEach [Quarter]) In Report)) In
[Quarter]) / (Count ([Quantity sold] ForEach [Quarter]) - 1)

This formula is clearly unwieldy. By using variables you can simplify it to:

## Example: Showing prompt input with the UserResponse function:

You want to show the state that they have chosen in the report title. If your data
provider is called eFashion? and the text in the prompt is Choose a State?, the formula for the
title is:

## Percentage ([Sales Revenue])

Example: Calculating a percentage using the Sum function:

In the following table the Percentage of Total column has the formula:

## If [Revenue]>10000 Then "High" Else "Low"

Calculation context:

## = Min ([Sales Revenue] In([Year];[Quarter])) In ([Year])

ForEach is used to include a dimension in a context. The calculation context is still affected by
other values in the block.

## ForEach Operator : = Max ([Sales Revenue] ForEach ([Quarter])) In ([Year])

In is used to specify exactly which dimensions to include in a context. Other dimensions
in the block are ignored.
In Operator : = Max ([Sales Revenue] In ([Year];[Quarter])) In ([Year])

ForAll is used to exclude a dimension from a context. Other dimensions of the block will still be
considered.

## Break keyword = Sum ([Sales Revenue]) In Break

Block keyword = Average ([Sales revenue]) In Block

## Report Keyword = ([Sales revenue] / (Sum([Sales revenue]) In Report)) * 100

(Percentage of Total column)

## In a block, the Report includes all data in a report

= ([Sales revenue]/Sum([Sales revenue] ForAll
([Year];[Quarter]))) * 100

## The formula for the Percentage of Total column is:

([Sales revenue]/(Sum([Sales revenue]) In Report)) * 100

In a block, the Report includes all data in a report, so this formula could be
written:
([Sales revenue]/Sum([Sales revenue] ForAll ([Year];[Quarter]))) * 100