Hi everybody,
How can I calculate a price average between two input date? I need let the user choose a start and end date to calculate a price average between this interval. I've tried to use a dropdown list, but the dropdown list filtered all my chart (the same to the slider) and I need just define a date interval to calculate and put the result in a simple text input (or any other out type to user visualization), without change my chart or data table. Thanks!
Hi Thiago,
I would suggest you to use the Slider object to enter the date.
To avoid the date filter to change the information in all objects in your report, you can use the Slider inside a Container in your Report and instead of using the Filters in the Section Prompt.
This way you will have to create interactions within your Slider (Date Filter) and the objects that you want to filter, than you would have filtered only the objects you want an not all the report.
Once you have the date defined you can select your 'PriceInformation' table in your data source and change the aggregation to Avegare.
Maybe you want to duplicate your 'PriceInformation' data so you would have both, the Sum and Average, here are some screenshots.
I hope it helps!
How can I calculate a price average between two input date?
But what exactly is the problem? You make it sound as if computing an average is the problem, that's your first sentence and title. Surely that can't be the actual problem. Is the real problem how to let the user define the interval?
Hi, PaigeMiller, thank you!
"May I ask what part of SAS you plan on using to allow the user to enter dates"
I thought about using two text input to allow the user to enter dates, using two parameters to convert text to date, but I do not know how can I use those two dates to calculate an average between the interval.
"Is the real problem how to let the user define the interval?"
If you have a better suggestion to let the user define the interval, I would be grateful to know. As I sad, I've tried to use two dropdown list, but the dropdown list filtered all my chart =\
Thanks and sorry for my English.
Hi Thiago,
I would suggest you to use the Slider object to enter the date.
To avoid the date filter to change the information in all objects in your report, you can use the Slider inside a Container in your Report and instead of using the Filters in the Section Prompt.
This way you will have to create interactions within your Slider (Date Filter) and the objects that you want to filter, than you would have filtered only the objects you want an not all the report.
Once you have the date defined you can select your 'PriceInformation' table in your data source and change the aggregation to Avegare.
Maybe you want to duplicate your 'PriceInformation' data so you would have both, the Sum and Average, here are some screenshots.
I hope it helps!
Hi gcarvalho, thank you for the help!
I'll try your tip and come back here to tell you if it worked!
Thanks!
Thank you gcarvalho, your solution worked perfectly for me!
You can see the result in the attached image, thank you.
Hi Thiago,
I'm glad to see that it works for you.
Looks like you are doing some reports in Portuguese, good to see SAS users from Brazil or Portugal maybe.
Thanks and best regards!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.