Skip to main content
Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.

Summarize Data with Summary Variables

Learning Objectives

After completing this unit, you’ll be able to:

  • Describe how summary variables represent a summary of data.
  • Apply a summary variable to a price rule.
  • Create a composite summary variable.
  • Limit which records contribute to summary variable values.

Pick a Peck of Pickled Peppers

Let’s set the scene: It’s summertime, you’re preparing dinner for your significant other, and you want to make a salad using fresh vegetables from your own garden. Sounds pretty pleasant, doesn’t it? So you grab a basket to do some harvesting, and this is what you come back with:

Vegetable Color Weight (grams)
Bell Pepper Red 268
Bell Pepper Orange 282
Cherry Tomato Red 30
Cherry Tomato Red 37
Cherry Tomato Red 25
Cherry Tomato Red 26
Cucumber Green 431

Yes, you weigh each vegetable because that’s just the kind of person you are. Don’t let anyone tell you data isn’t fun! And there are a lot of “fun” ways we could summarize the data, for example:

  • Count of vegetables: 7
  • Sum of pepper weight in grams: 550
  • Average tomato weight in grams: 29.5
  • Minimum weight of any vegetable in grams: 25
  • Maximum weight of red vegetables in grams: 268

Good news, the fun isn’t limited to gardening. Salesforce CPQ has a tool that’s designed to summarize data just like above: Summary Variables. But instead of summarizing vegetables, it summarizes CPQ-related records. These include quote lines, product options, subscriptions, and assets (which is a core Salesforce object). So if you need to know something about those records, like how many active subscriptions does a customer have right now, you can make a summary variable to represent that value. Then, in a price rule, you can reference that summary variable in price conditions or price actions.

Plant a Summary Variable Seed

Let’s consider a use case that benefits from summary variables as a factor in a price condition. AW Computing wants to promote customer retention. It wants to reduce the price of laptops by $100 if the customer has bought more than 10 of them in the past. The company knows what the customer has previously purchased thanks to asset records related to the account.

Asset related list on an account record.

What you need to know is the sum total of laptop asset quantities. You can make a summary variable to represent exactly that.

  1. In the navigation bar, click Summary Variables.
  2. Click New.
  3. For Variable Name, enter Laptop Asset Sum.
  4. For Target Object, choose Asset.
    This picklist contains the other kinds of records you could possibly summarize.
  5. For Aggregate Function, choose Sum.
    Just like you could summarize your vegetable harvest in various ways, you can summarize records using count, sum, average, minimum (min), and maximum (max).
  6. For Filter Field, choose ProductCode.
    Be sure to choose “ProductCode,” not “Product Code.” The first is the API name of the Product Code field on the asset object, and was added to the picklist by Team Trailhead. The second generically represents the Product Code from the product object, and won’t work in this example.
  7. For Operator, choose starts with.
  8. For Filter Value, enter LAPTOP1.
    This will pick up 13" and 15" laptops, but not laptop carts.
  9. Click Save.

Great, now anytime you want to know how many laptop assets are on an account, you can just refer to Laptop Asset Sum. With this variable in hand, let’s make a price rule.

A Condition with a Dash of Summary Variable

The price rule you need to create for AW Computing is quite similar to what you’ve made other units. As before, you start with a price rule record.

  1. In the navigation bar, click Price Rules.
  2. Click New.
  3. For Price Rule Name, enter Repeated Laptop List Price.
  4. For Evaluation Scope, choose Calculator.
  5. Check Active.
  6. Click Save.

This rule should only run under two conditions: The customer has bought 10 or more laptops in the past, and the quote line is for a laptop. The first condition uses your new summary variable.

  1. In the Price Condition related list, click New.
  2. For Object, choose Summary Variable.
  3. For Tested Variable, find and choose Laptop Asset Sum.
  4. For Operator, choose greater or equals.
  5. For Filter Type, choose Value.
  6. For Filter Value, enter 10.
  7. Click Save.

The second condition makes sure the adjustment occurs for only laptop products.

  1. In the Price Conditions related list, click New.
  2. For Object, choose Quote Line.
  3. For Field, choose Product Code.
  4. For Operator, choose starts with.
  5. For Filter Type, choose Value.
  6. For Filter Value, enter LAPTOP1.
  7. Click Save.

Doing good! The last step is to create a price action to adjust the price book price by subtracting $100.

  1. In the Price Actions related list, click New.
  2. For Target Object, choose Quote Line.
  3. For Target Field, choose SBQQ__ListPrice__c.
  4. For Formula, enter SBQQ__OriginalPrice__c - 100.
  5. Click Save.

And there you go, one summary variable-based price rule, ready to be tested. Let’s navigate to an account before you go into a quote so that you can see what assets exist there, and if you should expect a price adjustment for laptops.

  1. In the navigation bar, click Accounts, then choose the All Accounts list view.
  2. Click GenePoint.
  3. Click the Related tab.
    If you scroll down the page a little, you see a related list for Assets. In total, there are 10 laptops, so GenePoint should see a reduced price for laptops on its next quote.
  4. In the Quotes related list, click Q-00051.
  5. Click Edit Lines.
  6. Click Add Products.
  7. Check LAPTOP13.
  8. Click Select.
  9. Click Save.
  10. Click the quote line drawer arrow (Quote Line Drawer expand icon ) for the LAPTOP13 quote line.
    Your price rule should have run, making the List Unit Price $1200, exactly $100 less than the Original Price. Excellent job!
  11. Click Cancel.

When you created your Summary Variable for this exercise, you left the Aggregate Field set to Quantity because you needed to sum quantities. But if you have a scenario where you need to sum another numeric field (for instance, the weight of garden vegetables) you can add the API name of the field into the Aggregate Field picklist. This opens up a lot of possibilities for using summary variables in price rules.

Composite Summary Variables

There’s one more way to extend the already amazing capabilities of summary variables. What if you have a summary variable that sums the weight of bell peppers, but you need the weight in ounces, not grams that the source data provides? Salesforce CPQ can help with that, right in the summary variable record.

You may have noticed a section named Composite Information. The fields in this section allow you to perform a last-minute calculation against whatever value CPQ has summed so far. Knowing that 1 ounce is about 28.3495 grams allows you to do a little division to convert to the unit you need. Here’s what the summary variable would look like if you used composite fields for post-processing.

Summary variable record with Composite Operator and Value Element fields highlighted.

You would choose Divide for the Composite Operator, and enter 28.3495 into the Value Element field. Now the summary variable represents 19.4, the exact weight (in ounces) of bell peppers. The Composite Operator also supports addition, subtraction, and multiplication.

Finally, if you really want to get fancy with summary variables, you can use the Variable Element lookup field to reference another summary variable. For example, you could make a second summary variable that sums the quantity of laptops currently on the quote, then use the composite section to add in the summary variable you created in this exercise. That would give you a combined sum of asset and quote line laptops. The possibilities are endless.

Limiting Records with the Constraint Field

In this exercise you created a summary variable that filtered products by product code. But sometimes you need to put a second filter in place. For example, you might only want to sum laptops that were sold in the last year.

You can layer on another filter by using the summary variable’s Constraint Field field. The mechanics of setting up a Constraint Field are a bit complicated, but they mirror exactly how you would use the Constraint Field on a Discount Schedule, as seen in the fifth unit of the Discounting Tools in Salesforce CPQ badge. To summarize, you would:

  • Create a field on the asset to distinguish which assets should be included.
  • Create a field on the quote with the same API name as the asset field.
  • Through formulas, automation, or manual entry, populate the two fields to have the same value.
  • Set the Constraint Field field on the summary variable to the API name of the two fields.

It’s a bit of an effort, but it should be a one-time set-it-and-forget-it process.

Note

There’s a known issue that prevents summary variables from working when the Constraint Field is populated. This help article has a few workarounds.

Now that you know how to grow a garden of summary vegetables, er, variables, you’re ready to handle all sorts of complex price rule requirements. In the next unit you learn how to drive rule behavior using your own set of custom data.

Resources

Teilen Sie Ihr Trailhead-Feedback über die Salesforce-Hilfe.

Wir würden uns sehr freuen, von Ihren Erfahrungen mit Trailhead zu hören: Sie können jetzt jederzeit über die Salesforce-Hilfe auf das neue Feedback-Formular zugreifen.

Weitere Infos Weiter zu "Feedback teilen"