BookmarkSubscribeRSS Feed
SAS Employee

Hi VA experts,


I'm working on a report to compare the YTD revenue of this year to the previous year. I was able to calculate the YTD revenue from the beginning of the year to the current date. However, there is some future revenue that was captured in the data therefore I want to include revenue from the beginning of the year to end of the current month.  I could manually select the last day of the month for this year and last year. I was wondering there's a better way to do that without any manual effort.YTD (beginning of the year - end of current month)YTD (beginning of the year - end of current month)

Thank you for any help you can provide!

Opal | Level 21

One way to do this is to add month and year counters to your VA load table. Set it to 0 for the current month / year, -1 last month / year, -2 for the month / year before that and so on. This would be automatically created each time you update your VA load table.


Then a simple static filter to get current year would be: where year_counter = 0 and month_counter <= 0, and for last year: where year_counter = -1

SAS Employee
Thank you for your response! Can you provide more details on how to implement it in VA? Thanks!
Opal | Level 21

Here's how you can calculate a month and year counter based on a reporting date:

data want;
  set have;
  Reporting_Month = intck('MONTH', Reporting_Date, today()); 
  Reporting_Year  = intck('YEAR', Reporting_Date, today());

I'm assuming here that you can do this in "normal" SAS before you load into VA.

Rhodochrosite | Level 12

I've made the best experiences with a report_date variable in the data prep step via code.

You can use it easily in filters then. 


I'm not sure if this screenshot helps you out, but it shows well how the parallel period reacts to filters. 

good luck








Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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
  • 3 in conversation