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.
Thanks
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
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:
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)."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!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.