BookmarkSubscribeRSS Feed
sc5
Obsidian | Level 7 sc5
Obsidian | Level 7

Hi, 

 

I have a bar chart of y vs x. The aggregation of the y variable is set as sum by default. I know I can change this in the data object, but is there a way to add a drop-down toggle for a report viewer to select whether they want to view the sum or average in a specific bar chart? 

 

I assume we can do this with parameters, but I'm not sure how to set up the calculated field to make this work? 

 

Thanks

4 REPLIES 4
HunterT_SAS
SAS Employee

This blog I think should help you out:
https://blogs.sas.com/content/sgf/2016/04/27/use-parameters-to-pick-your-metric-in-visual-analytics-...

It was written several years ago but the same concepts apply to current  versions of Visual Analytics.


One minor change to it I might recommend is instead of using the same datasource to create the custom category, I would use a completely separate dummy datasource. If you use the same datasource then there is a small risk of accidentally filtering report objects when you did not intend to. 

acordes
Rhodochrosite | Level 12

I agree with @HunterT_SAS 

 

@sc5 Create a promoted table (and save to sashdat at the same location) and load into your report. 

Use in this case the _ch_number variable for customized category. 

Send some values to one category and name it 'Sum'. 

Assign 'Mean' to the other one. 

Use this customized category in a object like a button. 

Assign a parameter to it. 

 

For your target object create a variable like if parameter='Mean' then mean_variable, else sum_variable.  

data casuser.dummy_for_va(promote=yes);
do _num=1 to 100;
_ch_number=put(_num, words100.);
output;
end;
run;
sc5
Obsidian | Level 7 sc5
Obsidian | Level 7

Thank you! I've got that, I just don't understand how to set up the actual y variable to be graphed? If I try creating a calculated field like "If parameter1 = "Average" then return avg(bygroup,yvar) else return sum(bygroup,yvar) it doesn't let me, it just underlines the "if" in red and doesn't let me create the field. 

HunterT_SAS
SAS Employee

What version of Visual Analytics are you using? The calculation you described should be fine but maybe it's just a syntax problem ('IF' vs 'If' for example). 

For instance this one is fine for 2024.05:

HunterT_SAS_0-1718313773624.png

If that's not it, can you share a screenshot of what you have?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 289 views
  • 2 likes
  • 3 in conversation