Win – Loss Graphs in Reporting Services 2008

As I mentioned previously, SSRS 2008 allows us to use some nice visualisation techniques in our reports.  WinLoss 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:

        WHEN [SalesAmount] > 10000
        THEN 1
        WHEN [SalesAmount] < 10000
        THEN -1
        WHEN [SalesAmount] IS NULL
        THEN 0
    END AS Winlose

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:

    KPITrend("Internet Revenue")
    [Customer].[Customer Geography].[Country].members
    [Adventure Works]

Now lets add a chart – pick the standard column chart and format as follows:

  1. Right click and delete the chart title and legend;
  2. Right click on both the axis titles uncheck Show Axis Title;
  3. 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;
  4. Right click again on the Y axis and uncheck Show Axis;
  5. 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:

    1. Drag your Time field from the Report Data pane into the category area;
    2. Drag your Value  field into the Data Field area;
    3. 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:
    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:

  1. Add a table and delete the third column;
  2. Set the DataSetName property to the same as your chart;
  3. 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;
  4. Delete the bottom row;
  5. Drag your Series field into the First column, second cell;
  6. Drag your chart into the second column, second cell.

Finally add a bit of formatting to your table and you’re done!


This also works in SSRS 2005 – though doesn’t render quite a cleanly.