Hi,
I am trying to make a line chart in which the user can select which and how many lines are graphed. For simplicity, let's say I have two lines - 1. the number of pageviews to website A each month and 2. the number of pageviews to website B each month. The X axis is time (months) and the y axis is number pageviews. I want users fo the report to be able to select just the information for website A, just website B, or both.
My source data looks something like this:
Month Website A Website B
Jan 5 20
Feb 2 25
Mar 3 30
I tried just adding a drop-down box to the line chart, but it seems I have to add a single category variable (ex. month), so that wouldn't work since I would want the two numeric variables added (i.e. Website A and Website B).
I also tried adding filters and an interaction. I tried making Website A and Website B filters, but it seems I can't add interactions to line charts. But I also tried this same concept but with a bar chart, and I couldn't seem to create it that way either.
I'm using SAS VA Cloud (a free trial).
Any ideas? What am I missing? Does it just have to do with how my data is structured?
Three steps (haven't checked syntax):
1. Create a Paramater called Selected Pageviews
2. Create a new calculated measure called Pageviews with a IF THEN ELSE statement that checks the value of the paramater. For example:
IF 'Selected Pageviews'p = 'Website A' THEN 'Website A'n
ELSE WHEN 'Selected_Pageviews'p = 'Website B' THEN 'Website B'n
ELSE RETURN 0
END
3. This is the tricky part. You need to create a calculated category that will contain 2 values (Website A and Website B) so that a dropdown or button bar selector can be populated for the paramater selection. I try to find a category in the data that I know will not every be filtered out completly and assign the values to a group. Maybe use a Custom Category instead of a calculated category will work best. Once that's created then assign the paramater to the control (dropdown or button bar) and use the new Pageview measure on the line chart. Don't use the Website A/B measures anymore on the visualizations. When you change the button bar or dropdown the line chart should change.
Hope this helps!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.