Analysis Services calculations are great for storing formulas that your users need to see on a regular basis. They also have another little feature that adds just a little more wow when your end users browse the cube.
By building a color expression on a calculation you can change either the fore color or background color of a measure value. Here you can write an MDX expression that will change the font or background color of a cell when a user selects the calculation. A very basic example is below.
This example is actually not dynamic but here is exactly what it does:
IIF([Measures].[Profit Margin] < .40, 255 , 0)
IIF( boolean expression, true part, false part) ßVery similar to an IIF statement in SSRS expression language.
So if the profit margin is less than 40 percent I want my text to be red (represented by the 255) otherwise I want the text to be black (represented by the 0). The color panel to the right of the expression window is where you can select the color codes.
Here is what the result looks like in the cube brower:
The great thing is the text formatting is also carried over to Excel shown below:
Unfortunately, this formatting is not carried over to reporting services but luckily to simulate this same formatting in your report the expression looks very similar:
=IIF(Fields!Profit_Margin.Value < .40, "Red", "Black")