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.
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.
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.
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.
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.
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.
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 _ .
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.
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.
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.
To do this, you will need to define a new Display Rule for each available intersection.
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.
The base expression in this example is a Quick Calculation generated from the Expenses (staffing) column.
The scoped aggregated measure definition looks like this. Notice that I used the COMMA format.
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.
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.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.