You are on page 1of 3

Example: Showing average revenue per sale

[Sales Revenue] / [Number Sold]

Example: Create a formula to return a statistical variance:

To calculate the variance manually you need to:

calculate the average number of items sold

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

add up all these squared differences

divide this total by the number of values 1

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:

Sum ([Difference Squared])/[Number of Observations] - 1)

For example, the formula Average([Revenue]) appears in a cell as =Average([Revenue]).

The text Average Revenue?" appears as ="Average Revenue?"

The cell text is as follows: ="Average Revenue: " + Average([Revenue])

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:

"Quarterly Revenues for " + UserResponse( "eFash ion";"Choose a State")

Example: Calculating a percentage using the Percentage function

Percentage ([Sales Revenue])


Example: Calculating a percentage using the Sum function:

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

=[Sales revenue]/(Sum([Sales revenue] In Report))

and the Percentage of Year column has the formula:

=[Sales revenue]/(Sum([Sales revenue] In Section))

Variables: Average Sold = Average([Quantity Sold] In ([Quarter])) In Report

Number of Observations = Count([Quantity Sold] In ([Quarter])) In Report

Difference Squared = Power(([Quantity sold] - [Average Sold]);2)

Variance = Sum([Difference Squared] In ([Quar ter]))/([Number of Observations] - 1)

Sum ([Difference Squared])/[Number of Observations] - 1)

Operators: [Sales Revenue] - [Cost of Sales]

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

Calculation context:

Input contexts = Sum ([Revenue] In ([Year]))

= Sum ([ Revenue] In ([Year];[Customer]))

Output context = Min ([Revenue]) In ([Year])

= 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.

ForAll Operator : = Sum([Sales Revenue] ForAll ([Quarter]))

Section keyword = Sum ([Sales Revenue]) In Section

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


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

Body keyword = Sum ([Sales Revenue]) In Body

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