blog

Add Flexibility to Your SAS Visual Analytics Report

06/16/2016 by Craig Willis Modernization - Analytics

One of the most important components of an effective report is giving your end-user simple and relevant ways to control the report.  Static reports that provide only one view with no additional controls don’t allow your user to ask additional questions or find truly meaningful insight into the data.  An important piece of this puzzle is how you let your user control their date ranges.  SAS Visual Analytics offers some impressive date filter and hierarchy tools but there are times when a more advanced approach is needed.

Quick what date was 90 days ago?

The date slider filter in SAS Visual Analytics is a useful tool for providing a user with a very detailed level of control over the report.  It allows the user to ask specific questions about the data and get the answers with simple controls.

This begins to fall short though when users begin looking for relative date ranges like 30/60/90 days.  It requires the user to know the exact start and end date of the range they want to view.  In this case, we can use parameters to add this type of functionality to a report and provide a user with a more meaningful experience.

Creating a Dynamic Lookback Range Using a Parameter

Here is the functionality I am looking to create:

I want a line graph that shows daily totals for a given measure over a date range. Then while looking at this graph I want the user to be able to enter a number of days to look back from today (as opposed to figuring out what day was 90 days ago) into a text box and have the graph filtered for that date range.

In order to do this I need to do three things:

  1. Create a parameter to store the lookback period.
  2. Create an input control so that my user can edit the parameter
  3. Add a filter to my graph that will apply that parameter value.

Creating a New Parameter

Creating a new parameter is an option under the drop-down where new calculated measures and categories are created.

When creating a new parameter SAS Visual Analytics requires you to put some guard rails around the values a user can select.  For this example I want the user to be able to select any value between 30 and 180 days with the default value being 90 days.  This prevents my user from selecting a number outside what is practical for my data set as well as providing a default display if nothing has been entered.

Giving Control to the User

Next, I have to give control of this parameter to my user so they can enter the values (within my guidelines) that control the graph.  Since a parameter has to carry one and only one value I need to use an object control that that can only take one value.  That means I can select between a button bar, a drop-down list or a text box.  In this case, I want the user to be able to type the number in so I am going to go with a text box.

Finishing the job:  Filtering with your Parameter

Last but not least it is time to create the functionality that we outlined earlier.  I’m going to do this with an advanced filter that I will apply the graph.  I want the filter to show me any dates that are between Today – [my parameter] and today.  So if the user enters 30 the graph will show me the last 30 days.

Once I add this filter to a graph I can now have users enter the desired number of lookback days and immediately.

sas va parameter example

Parameters can be a very flexible tool when dealing with dates in SAS Visual Analytics, beyond just a number of days.  They can be applied to any level of the date hierarchy and can be used to create a broad array of end-user functionality.  I