BookmarkSubscribeRSS Feed

SAS VA Report Example: Add a scope to an aggregated measure

Started ‎11-30-2021 by
Modified ‎01-27-2022 by
Views 5,583

A scoped aggregated measure calculation is an expression defined for a specific crossing of categories. When thinking of a crossing of categories, it’s easiest to visualize a Crosstab object and the intersecting columns. The purpose of adding a scope to an aggregated measure, is that you want a specific type of expression returned for that intersection which is different from the other base cells around it.

 

I have recorded an accompanying video tutorial for these examples so that you may follow along.

 

 

Identify the Intersection

In this example below, we have Facility Region assigned to the Rows Role and Date by Year assigned to the Columns Role. I’ve highlighted the value $1,466,314 and we can see the intersection of South and 2010 clearly.

 

Abstractly, we would identify all of these cells as the intersection: Facility Region/Date by Year. So in this case, we do not yet have any unique intersections to manipulate with a scoped aggregated measure.

 

01_SimpleCrosstab.png

Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.

 

 

Adding an additional Row Role of Facility and turning on Subtotals will give us additional cells that we can use to apply a scoped aggregated measure. Now take a look at the Crosstab object. Notice the same value $1,466,314 is circled below, but since we have the additional Row assignment we have more cells, and we can now define a scoped expression for the intersection: Facility Region/Date by Year which is highlighted in purple below.

 

02_IdentifyIntersection.png

 

Add a scope to an aggregated measure

First, it’s good to understand the current base expression for all of these cells. The base expression, in this example, is simple and SUMs all of the underlying values _ ByGroup _ .

 

For a straightforward clear example, let’s scope the expression for the intersection Facility Region/Date by Year to be the AVG for each _ ByGroup _ .

Start by creating a new Calculated item by using the + New data item menu.

 

03_NewCalculatedItem.png

 

 

Next, let’s create the base expression for all of the cells to use. Remember, that’s the SUM _ ByGroup _ . Notice that once you add an Aggregated Operator to the expression that it is assigned to the Base expression scope automatically.

 

04_BaseExpressionSUM.png

 

 

Next, we need to add the scope for the Facility Region/Date by Year intersection to be the AVG for each _ ByGroup _ .

 

First, use the + button to add a scope. Next, define the intersection by moving over the columns, hint: order matters. And at the bottom, you can leave the Start scope with Blank expression selected then click OK.

 

05_NewScope.png

 

Once the scope’s intersection has been defined then we can build the expression. Remember, in this example we want to expression to be the AVG for each _ ByGroup _ .

 

06_ScopedExpressionAVG.png

 

If we add our new expression to the Crosstab object, we can see how the base expression is used for all of the cells except for the intersection Facility Region/Date by Year where we can see the scoped expression being used.

 

07_ScopedAggMeasureExample.png

 

Scoped Aggregated Measures in other VA Objects

 

From this simple example, you can easily see how the scoped aggregated measure is used in this Crosstab object. But scoped aggregated measures can be used in other VA Objects too. You just have to be sure you are meeting the intersection criteria if you want the object to use the scoped expression versus the base expression.

 

In the below example, I have shown two Bar Chart Objects with the same scoped aggregated measure assigned to the Measure Role: Expenses (staffing) Scope with Avg. The only difference in Role assignments is that to meet the scoped intersection criteria, I have assigned the Date by Year to the Group role.

 

One nice thing about the auto generated titles for the Bar Chart object, is that you can easily see the difference in the blue Bar Chart where there is only Facility Region versus the red Bar Chart where there is Facility Region grouped by Date by Year.

 

08_ScopedAggMeasureBarChart.png

 

Tip to identify complex Intersections

I have gone through a simple example, but what if you had a more complex Crosstab object that you needed to create scoped aggregated measures for? How can you determine the intersections? The easiest way is to use Display Rules to assist.

 

Create a Display Rule for any measure where the condition will be met, and then color the background of the cells different colors so that you can easily determine the intersections.

 

Notice that I kept the same purple highlighting for the intersection Facility Region/Date by Year consistent with the above example.

 

09_DisplayRules.png

 

 

To do this, you will need to define a new Display Rule for each available intersection.

 

10_AvailableIntersections.png

 

Limitations of Scoped Aggregated Measures

One of the limitations you might run into, is if you want a scoped expression to have a different format from the base expression. Unfortunately, at this time, there is no way to dynamically assign formats.

 

Therefore, as in the below example, choose to use a COMMA or NUMERIC format for the measure so that the report viewers do not make the wrong assumption about the measure.

 

11_FormatLimitation.png

 

The base expression in this example is a Quick Calculation generated from the Expenses (staffing) column.

 

12_PercentOfColumnCalculation.png

 

The scoped aggregated measure definition looks like this. Notice that I used the COMMA format.

 

13_ScopedAggMeasureExample.png

 

 

Additional VA Report Examples and aggregated measure tips:

More of my Visual Analytics related materials:

How to prompt for a date range in a SAS Visual Analytics report Blog Series:

 

Find more articles from SAS Global Enablement and Learning here.

Version history
Last update:
‎01-27-2022 02:59 PM
Updated by:
Contributors

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags