How to do aggregations in Salesforce Marketing Cloud?

How to do aggregations in Salesforce Marketing Cloud? - DESelect Blog

Would you like to be able to find the number of orders each customer has made in a certain period of time? Or calculate the average order value for each customer? Or maybe you want to count the number of emails sent to each subscriber in the last 30 days? All that and more is possible with the aggregation functionality in Salesforce Marketing Cloud.

In this article, we will explain how to use aggregations in Salesforce Marketing Cloud (SFMC) using SQL and DESelect.

How to use aggregations in SFMC using SQL

SQL is great at aggregating data the way you might in a pivot table in Excel. The functions are similar to what you’ll find in Excel or certain analytical tools. For instance, The GROUP BY statement groups rows that have the same values as summary rows, like “find the number of customers in each country”.

The GROUP BY statement is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()), to group the result-set by one or more columns. Here you can find a brief explanation of what each function means:

  • AVG – calculates the average of a set of values
  • COUNT – counts rows in a specified table or view
  • MIN – gets the minimum value in a set of values
  • MAX – gets the maximum value in a set of values
  • SUM – calculates the sum of values.

In this article, we’re going to dig deeper into the COUNT aggregation that allows you to do a count on a data extension or data view and store the results in your target data extension.

In the scenario we’re going to demonstrate, we’d like to know the number of times each subscriber has opened an email in the last 30 days.  On top of that, we’d also like to limit the result to the first 20% of subscribers.

Here’s how the SQL query for the following scenario will look.

Aggregations SQL that you can do in DESelect

(SQL query using Aggregations)

In our example, we’re using the Customers data extension along with the data view _Open. Normally, an aggregation is only a part of the segmentation a marketer has to perform. However, for non-technical marketers it can sound like a challenge. Fortunately, there are alternatives to writing SQL in SFMC if you want to use aggregations… like DESelect!

How to use aggregations in SFMC using DESelect

In the video below you can find a step-by-step guide to using aggregations in DESelect.

For convenience, DESelect offers different screens depending on the level of the marketer’s maturity. For instance, if you don’t know how your data model is set up exactly, you can use the ‘Basic’ screen, where the relations between your data extensions are already pre-defined. In the video, for example we’re using this screen to create an aggregation. However, if you are more confident with your data model, you can use the advanced screen. You can read more about how to create a segment using the advanced aggregation screen here.

If you’d like to book a live demo to see how DESelect avoids the need for code in your advanced segmentation, one of our experts would love to help you.

Conclusion

In this article, we explained how to use aggregations in Salesforce Marketing Cloud using SQL and the no-code alternative, DESelect. If you want to see DESelect live and leverage aggregations with an easy drag-and-drop, book a demo with one of our experts.

Latest Articles

  • Unlocking Salesforce Data Cloud’s Consumption-Based Pricing

    Unlocking Salesforce Data Cloud’s Consumption-Based Pricing A Practical Guide for Marketing Teams   1.Introduction Ever since its grand reveal in Dreamforce 2023, Salesforce Data Cloud has been the company’s spearhead product. Data Cloud is a powerful tool that, when used wisely, can lead your marketing to new heights. Salesforce Data Cloud combines hyperscaler performance, real-time […]
  • Take the DESelect Marketing Operations Maturity Model Assessment

    Take our free survey to assess and advance your marketing operations maturity model along two dimensions: automation and personalization. You'll receive your customer report in just a few days.
  • Beyond Limits – Exploring Smart Communication Capping

    Beyond Limits: Exploring Smart Communication Capping In this comprehensive guide, we explore why communication capping matters and how smart communication capping maximizes engagement, marketing ROI, and compliance.  Why Communication Capping Matters In today’s landscape, customers can be overwhelmed with marketing messages across multiple channels. In our 2024 study of 234 consumers across the United States, […]
  • Top 10 Marketing Operations Predictions for 2025

    We’re excited to unveil our Top 10 Marketing Operations Predictions for 2025. The exponential growth of marketing automation, the impact of AI on strategy and execution, and the drive to become more intentional and data-driven means we’re going to see a lot of interesting dynamics and progress in marketing. As 2024 closes out, we took a step back to think about what the future holds for marketing operations and came up with our first-ever list of predictions. Let’s dive in!

Join our newsletter to receive updates and helpful SFMC guides.

Reach the most targeted<br/> audiences in half the time

Reach the most targeted
audiences in half the time

Deselect icon
Subscribe to the Newsletter
Receive Salesforce Marketing Cloud tips,
tricks, and DESelect updates

By clicking the “Subscribe now” button, you agree to the DESelect Terms of Use and Privacy Policy.