BookmarkSubscribeRSS Feed
gjanuary
Calcite | Level 5

Create Custom Date Items to be used for Display or Calculations. This example will create three Items. A Date for the Previous Monday and a Date for the Previous Friday. These will be used to aggregate data between those dates. The aggregation uses the two custom dates and a date column from your data that can be used for aggregation. This is a basic way of doing a one week lookback without using filters or creating parameters.

Using the Following you can copy paste into a new calculated item to create a static Data Element for The previous Monday's date. 

TreatAs(_Date_, ( ( ( TreatAs(_Number_, DatePart(Now())) - DayOfWeek(DatePart(Now())) ) + 2 ) - 7 ))

This code will create a date for the previous Friday.

TreatAs(_Date_, ( ( ( ( TreatAs(_Number_, DatePart(Now())) - DayOfWeek(DatePart(Now())) ) + 2 ) - 7 ) + 4 ))

TreatAs(_Date_, ( ( ( ( TreatAs(_Number_, DatePart(Now())) - DayOfWeek(DatePart(Now())) ) + 2 ) - 7 ) + 4 ))

Used together to create a custom calculation

In the following code date_str is a column from the data loaded to VA.

IF ( TreatAs(_Number_, TreatAs(_Number_, 'DATE_STR'n))
BetweenInclusive(TreatAs(_Number_, 'PrevMonday'n), TreatAs(
_Number_, 'PrevFriday'n)) )
RETURN 'CompletedAppointments'n
ELSE 0

IF ( TreatAs(_Number_, TreatAs(_Number_, 'DATE_STR'n))
BetweenInclusive(TreatAs(_Number_, 'PrevMonday'n), TreatAs(
_Number_, 'PrevFriday'n)) )
RETURN 'CompletedAppointments'n
ELSE 0

SAS Innovate 2025: Call for Content

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 0 replies
  • 266 views
  • 0 likes
  • 1 in conversation