As I mentioned previously, SSRS 2008 allows us to use some nice visualisation techniques in our reports. Win\Loss graphs are used to show (wait for it......) the trend of wins and losses over time. The usual example is the performance of a sports team during a season, but they are also useful for showing trends over time such as the performance of a KPI. Here's another quick how-to on building this type of chart in SSRS 2008.
So first we need a dataset with three fields: Series, Time and Value. The first two are fairly self-explanatory, for the third you need to transform your value so it appears as either a 1, -1 or 0 (win, lose, no result/tie). The AdventureWorks built-in cube KPI's work well here so I'm going to shortcut slightly and use these. If you're going to use a relational source you may need to do something a little cleverer. For example:
SELECT
[Month]
,[Country]
,CASE
WHEN [SalesAmount] > 10000
THEN 1
WHEN [SalesAmount] < 10000
THEN -1
WHEN [SalesAmount] IS NULL
THEN 0
END AS Winlose
FROM
[AdventureWorksDW].[dbo].[FactInternetSales]
We'll be using AdventureWorks (SSAS) "Internet Revenue" KPI. Don't forget that when using an AS data source in SSRS you basically have to trick it into thinking it's relational and make sure you have your measures on Columns (as Chris Webb discusses here). Here's our very simple MDX statement:
SELECT
KPITrend("Internet Revenue")
ON COLUMNS,
[Date].[Calendar].[Month].members
*
[Customer].[Customer Geography].[Country].members
ON ROWS FROM
[Adventure Works]
Now lets add a chart - pick the standard column chart and format as follows:
- Right click and delete the chart title and legend;
- Right click on both the axis titles uncheck Show Axis Title;
- Right click on the Y (vertical) axis and select Axis Properties. Under Axis Options set Minimum to -1, Maximum to 1 and Cross At property to 0 (this makes sure our baseline runs between the "wins" and "losses"). Click OK;
- Right click again on the Y axis and uncheck Show Axis;
- Right click on the X axis and select Axis Properties. Under Labels check Hide Axis Labels and do the same for Major and Minor Tick Marks. Under Line set the width to 0.5 and the colour to light grey or similar. Click OK.
You should now have something like this:
Now lets add some data:
- Drag your Time field from the Report Data pane into the category area;
- Drag your Value field into the Data Field area;
- Right click on your series and select Series Properties. Under Fill set the colour suitably. In our example we're going to show wins as black and losses as red using a switch statement in an expression:
=Switch
(
Fields!Internet_Revenue_Trend.Value = 1, "Black",
Fields!Internet_Revenue_Trend.Value = -1, "Red"
)
If you preview the chart now it should look something like this:
To finish off we need to add the chart inline to a table:
- Add a table and delete the third column;
- Set the DataSetName property to the same as your chart;
- Right click on the second row and add a group (using the adjacent above option). Select your Series value (in our case: Country) from the drop down;
- Delete the bottom row;
- Drag your Series field into the First column, second cell;
- Drag your chart into the second column, second cell.
Finally add a bit of formatting to your table and you're done!
As usual the sample report can be downloaded from the downloads section (don't forget to login).
This also works in SSRS 2005 - though doesn't render quite a cleanly.
So as the dust settles and everyone calms down, it's time to move on and get back to what we're good at! Just in case anyone was worried, we'll continue to be at the cutting edge of PerformancePoint Services and the MS BI stack as well as looking at SharePoint in more detail.
I thought I'd post this one as it's come up with a couple of our customers recently and isn't entirely clear at first glance. When you design an Analytic Chart or Grid in Dashboard Designer by default empty rows/columns (or series on a chart) are shown. If you want them to be hidden when the user first opens the chart/grid then click the browse button at the bottom right of the design pane:
The preview window will appear. Now click either of the two end icons on the toolbar (marked by the red rectangle below) to hide the empty rows/columns (or both)
When you click OK the setting will be saved into your design - you can verify this by going into the MDX view of the query and checking that "Non Empty" now appears in your MDX.
You can use the same method to apply sorting by right-clicking on a column in the browse window and selecting the relevant sort function.
Of course if you are using an MDX query then use the NonEmpty/Non Empty functions directly.
As I've pointed out before, don't forget the built-in Dashboard Designer help which is pretty comprehensive