BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MelCar
SAS Employee

Here is another way of doing this that allows you to filter the results for a rolling 30 days from the last date you choose. 

 

 

From the Data panel,  right click on your Date field (mine was called Date) and select Create Parameter from Data Item.

 

 Rolling30Days1.png

 

Name it Date Parameter and click ok.

 

Rolling30Days2.png

 

Now we’ll add a couple of calculated Items. The first one will hold the ending date.

From the Data Pane, select the Options icon, then click New Calculated Item.

 

Rolling30Days3.png

 

Name the new calculated item end date num. Click on the Text tab and cut and paste the following text:

TreatAs(_Number_, DatePart('Date Parameter'p))

 

Note: my Date field was a DateTime value so I had to add the DatePart function. If your field is a just a date value then you don’t need the DatePart.  Your text should read TreatAs(_Number_, 'Date Parameter'p)

 

 Rolling30Days4.png

 

Click Ok.

Select end date num and set the Aggregation to Average.

 

Rolling30Days5.png

 

Now we’ll create a new calculated item for the beginning date (30 days prior to our end date).

 

Using the Options menu again, select New Calculated Item.  Enter beg date num for the name.  Click on the Text tab and copy and paste the following text: TreatAs(_Number_, DatePart('Date Parameter'p)) – 29.

 

Remember: If your date field is not a datetime format you will need to remove the DatePart. Your text should read this: TreatAs(_Number_, 'Date Parameter'p) – 29.

 

Rolling30Days6.png

 

Click Ok.

Set the aggregation to Average for beg date num.

 

Rolling30Days7.png

 

Add a slider to your report and select the Properties tab and choose Single for the value.

 

Rolling30Days8.png

Under roles choose your Date field as the Measure/Date and choose Date Parameter as your Parameter.

 

Rolling30Days9.png

 

 

 

 

 Click Yes when the following pop-up message appears.

 

Rolling30Days10.png

 

Add a chart that you want to filter your data by the last 30 days for.  Set up your roles for what you want to display. In my case I added a time series line chart that is displaying Oxygen levels in water.

 

Rolling30Days11.png

 

Select the filters tab for your chart.  Click Add Filter, click on the Text tab and copy and paste the following text.  

 

 ( TreatAs(_Number_, DatePart('Date'n)) BetweenInclusive('beg date num'n, 'end date num'n) )

 

NOTE: if your Date field is not DateTime format you will need to remove the DatePart.  Also, your date field name maybe different from mine. So, you’ll have to change Date to the name of your date field.  Your text should read this: ( TreatAs(_Number_, 'Date'n) BetweenInclusive('beg date num'n, 'end date num'n) )

 

 Rolling30Days12.png

 

Your chart should now show a rolling 30 days depending on the date shown in the slider.

 

Hope this helps!

Melanie

 

SKG
Obsidian | Level 7 SKG
Obsidian | Level 7

Hi Victor, Sorry for late reply. Actually I faced the same issue. Try to do this way, it will work.

 

1) Create calculated Item 

calculated_item.png

 

2) Change format:- 

 

change_format.png

 

3) select the filed "Year" and right click on it and select Category option

 

change_to_category.png

 

4) Select slider object and then click the Rank tab

 

Select_Slider.png

 

5) Select "Year" then Click on "Add Rank" button then choose "Top Count"  from the drop down then make sure the radio button is selected as "Count". Then enter 10, 20, 50 and so on in the box (respectively this will give you the last 10 years, 20 years, 50 years and so on). And "By:" option select Registration_Date and Include "Ties".

Rank.png

 

6) After that, you can select min and max date only for one time and from the next day it will automatically selected max date as per data.

final_select_date.png

 

Regards,

Sunny

angeldbracho
Calcite | Level 5

Hi guys,

hope you are well. I'm having a little trouble with SAS VA 7.4, I'd be glad if you could help me.

 

I have data from two years: 2017 and 2018 (I'm interested in a numerical variable). I put a slider (period) that's filtered, to show only 2018 values.

 

slider.PNG

 

 

I want to make a bar chart, that shows, for a category, the cumulative amount for the selected period in the slider (no problem with that) but also the cumulative amount for the same month in the previous year.

 

bar chart.PNG

The blue bars are ok but not the Green ones (cumulative period of the same month, previous year). I'm trying with the aggregated measure "cumulative period" set for previous year (-1) but it doesn't work, and don't know why, although it worked well when using it in a cross table with "period" as columns.

 

cumulative period.PNG

 

Can you help me?

 

Thanks and regards!!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 17 replies
  • 8530 views
  • 6 likes
  • 7 in conversation