Sample 65187: How to aggregate a measure for the four most recent quarters of the data in SAS® Visual Analytics on SAS® Viya®
Overview
This sample demonstrates how to aggregate a measure for the four most recent quarters using SAS Visual Analytics 8.4. For example, if you are currently in the third quarter of 2019, the four most recent quarters are fourth quarter 2018 through third quarter 2019. This sample calculates the most current date in the table by using a slider that has the Set value to dynamic maximum enabled. From the most current date, you calculate back three quarters to get your starting point. Once you have the starting point, you can create a filter on the object that you want to use to display the value.
The sample data source includes a date data item named Date.
Before you begin, perform the following steps:
- Create a new report in SAS Visual Analytics.
- Add your data source to the report.
Detailed Steps
- Add a slider control to the page. On the Options pane, under Slider, select Single Value for the Input Style. Select the Set value to dynamic maximum option.
- On the Data Roles pane, add the Date data item.
- Create a new parameter named Max Date and add it to the Parameter role for the slider. This is how the report might appear at this point.
- Using the Max Date parameter, create two data items that represent the year and the quarter.
- MaxYear = Year(Max Date parameter)
- MaxQuarter = Quarter(Max Date parameter)
- Create two data items that represent the starting point of the filter: FilterStartYear and FilterStartQuarter.
- Use the DateFromYQ operator on the FilterStartYear and FilterStartQuarter data items to get the starting point of the filter.
- Add a key value object to the report. On the Data Roles pane, add Frequency as the Measure.
- Add a filter on the key value object that calculates the frequency for the most recent four months. In this sample data, the most recent four quarters are shown in the following crosstab. Beneath the crosstab is the key value object.
Additional Resources
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Date Modified: | 2021-03-29 13:00:47 |
Date Created: | 2019-12-02 15:17:11 |
Operating System and Release Information
SAS System | SAS Visual Analytics (on SAS Viya) | Linux for x64 | 8.3.1 | | Viya | |
Microsoft® Windows® for x64 | 8.3.1 | | Viya | |