You are on page 1of 10

Jul 22 2007

Alerters on Charts: Part I


Categories: Full Client, Report Techniques, Variables! Dave Rathbun @ 12:28 pm

The Challenge
Officially there is no way to put an alerter on a chart. Yet some time back I was challenged by a client to create a line chart that was green if the overall trend was up, and red if the overall trend was down. This chart appeared in a sectioned report so there was a different chart for each section value. Possible? It turns out that there was an answer that works. With minor changes it works in both the desktop and the web products as well. The eFashion database and universe are used in this demonstration.

Solution using Business Objects 6.5


The first step is to get some data that will support this requirement. I selected the Lines objects from the Product class, the Year from the Time class, and the Sales revenue from the Measures class. Depending on your version of eFashion data you might have slightly different values but the 6.5 version of the database looks like this:

As you can see from reviewing the data the Accessories product line is in an overall downward trend if you take the first and last year as the only data points. City Skirts is in an upward trent, and City Trousers is again in a downward trend. I dont intend to do a true trend analysis with moving averages; I am going to make a very simple definition of up or down and use the first year and last year as my only two data points for this tip. The next step is to create a variable that determines the trend direction. I am going to need a variable because thats how I can determine which chart to show later on. The variable is hard-coded in this sample since I know what the end points are. The formula for the variable looks like this:

=Sign(<Sales revenue> Where (<Year>="2003") - <Sales revenue> Where (<Year>="2001"))

There are two components to this formula. The first is the Where clause on the measure value. This applies a filter to the revenue so that the value for the measure is filtered to a specified year rather than showing a total. The second component is the Sign() function. The Sign() function is fairly simple: it returns the numeric sign of the argument. If the argument is any positive value, no matter how big or small, the sign is +1. If the numeric argument is negative, the sign is -1. If the number is zero the sign is zero, and finally if the number is undefined the sign is also undefined. The results of this formula are shown here:

Notice that each product line has an appropriate trend, based on the difference in the 2003 revenues and those for 2001? I will be using this again shortly. The next step is to set up the chart. For this example I am going to use a simple line chart as it shows the trend in the most obvious fashion. First I created a section on Lines, and then a line chart with Sales revenue and the Year data. Heres what the first version of the chart looked like, and Im not entirely happy with the results:

What dont I like? Because of the difference in scale I can barely see the second chart as it is using the same scale as the first chart. Here is what I would rather see:

What I have done here is activate a setting that tells the report to use the scale within each section rather than for the overall report. I think its going to be much easier to read. Heres where that setting appears:

I now have a chart that I like, but it doesnt fit the requirement yet. All of the charts are green, even those that are in a downward trend. The next few steps will complete this tip and solve the problem. First, I will duplicate the chart so that I have two identical charts. I will then change the color on the second chart so that it is red. (At the same time I increased the weight of the line just to make the charts more visible.) Heres where these steps leave me:

The final step is to ensure that only one of these two charts appears for each section. This is done by right-clicking on the chart, selecting Format Chart, and going to the Appearance tab of this dialog box. I started on the red chart and entered a Hide formula that looks like this:
=<Sales Trend> = 1

For the green chart I do something similar but use this formula instead:
=<Sales Trend> <> 1

Heres the screen where this is done:

What does this do? If the trend is positive then the red chart is hidden. If the sales trend is negative or zero then the green chart is hidden. So I get something like this:

Im almost to the end of the technique the last step is to carefully size and position the two charts so that they occupy the same space. Since I know only one or the other will ever be displayed I want them to be in exactly the same space. This provides the illusion that there is a chart alerter that is changing the color of the chart based on the trend of the sales data. The reality is there are two charts that switch places. Here is the final output:

Part II of this article will continue this idea and show how to accomplish the same illusion using techniques available in Web Intelligence.

Summary
The purpose of this article was to show how to simulate the appearance of a chart alerter. Since the tools do not provide this feature directly I used a variable and the hide block feature instead.

Functions Used

Sign()

You might also like