BookmarkSubscribeRSS Feed
Fluorite | Level 6

Hi SAS Community 


Is it possible to create a filter on a line graph to change the measure that is used in the graph? 

For example: I want the user to change the measure in the graph from Sales Rand to Sales Quantity. 



Rhodochrosite | Level 12

I suppose you're referring to Visual Analytics.

In case that's true yes you can do it by using a dummy table for creating a customized category, attach a parameter to it and use it in new data item within an if-then-statement. return the variable you want the user to select between. use this dynamic data item as role (for example x) in the graph. 

@Stu_SAS wrote a paper about it.


Mastering Parameters in SAS Visual Analytics

page 5-6

SAS Employee

Thanks, Arne! You are exactly right, a parameter is an effective way to do this. Here are two possible options:

1. Using Parameters
Works on: All versions of Visual Analytics

As Arne hinted, parameters are a very powerful concept and allow you to create things like dynamic variables that let you switch between one or more variables:


To create a dynamic variable with a parameter:

  1. Create a new Character parameter
  2. Create a new calculated variable and add the following code:
    if(upcase('Parameter 1'p) = 'LABEL HERE') return 'Var 1'n
        else 'Var 2'n
    Where 'LABEL HERE' refers to the value of the button the user selected, and 'Var 1'n/'Var 2'n refer to your variables you'd like to switch between. In the image shown above, the labels are "MPG (City)" and "MPG (Highway)."
  3. Add the new calculated variable to your graph
  4. Add a new button bar populated with the label names you would like to use. In the paper Arne linked, p. 6-7 shows one way to achieve this; however, you can create the same labels using your existing dataset. You'll need to be careful so that they do not get filtered out by report-level or page-level filters.

When users select buttons, the variable in the graph will automatically change. The downside of this is that the variable being shown has a static name. You'll want to add the parameter to dynamic text so that users are aware of what they are looking at.


2. Viewer Data Edits

Works on: VA 8.4+


If you change the Viewer Customization level for the report to "Data Edits" under the Report Options pane, report viewers can modify graphs to display which variables they would like to see:




This way the user can create their own analysis with the variables you leave unhidden.

Hope this helps!




Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1 like
  • 3 in conversation