Friday, April 1, 2011

Selecting a Single Value and Showing a Range

This post shows how you can use presentation variables to select a single value in a dashboard prompt and produce a result set that includes a range of values. For example, you could select a single year in a prompt and show data for that year and the preceding three years.

To make this happen, you first need to set a presentation variable with the dashboard prompt. In this screen shot, the variable's name is "Y".



The trickier part is constructing the filter in the query. It is going to constrain the values between two values, i.e. between Y and Y-3. In the filter, this will be between a SQL Expression (using the variable Y) and the variable Y itself. The screen shot shows how this was entered.



On the Criteria Tab, this filter will look like this.


Just one other thing is required: you have to click Protect Filter or it will be overwritten by the value you enter in the dashboard prompt.