Optimizing workload distribution through Territory Balancing

In this tutorial, we’ll explore how to optimize work distribution across teams by analyzing sales territory data to identify imbalances and redesign territories using CARTO Workflows.
Focusing on a beverage brand in Milan, we’ll use the Territory Balancing component, a feature available in the Territory Planning Extension Package, to evenly assign Point of Sale (POS) locations to sales representatives by dividing a market (a geographic area) into a set of continuous territories. This ensures fair workloads, improves customer coverage, and boosts operational efficiency by aligning territories with demand.
Setting up your workflow
Sign in to CARTO at app.carto.com
Head to the Workflows tab and click on Create new workflow
Choose the CARTO Data Warehouse connection or any connection to your Google BigQuery project.
Install the Territory Planning extension package if you do not have it already.
Now, let’s dive into the step-by-step process of creating a workflow to balance territories, ensuring each sales representative is assigned a manageable and strategically optimized area. You can access the full template here.
Imagine a field sales team responsible for visiting hundreds of restaurants across the greater Milan metropolitan area to promote and distribute a soft drink. When Points of Sale (POS) are assigned manually, territories often become unbalanced—some sales representatives end up with too many accounts to manage effectively, while others are left underutilized. This imbalance may lead to inconsistent store visits and missed sales opportunities. By balancing the POS to visit, Territory Balancing ensures that each sales rep is responsible for a fair and strategically valuable territory.
Loading the POS data
For this use case, we will consider restaurant point of sales (POS) in the city center of Milan from The Data Appeal Company, together with popularity and sentiment scores. The full dataset is available on demand in CARTO’s Data Observatory, but we have prepared a sample for you to easily follow this tutorial.
Once in your workflow, go to the Components section, and drag-and-drop the Get Table by Name component. Then, type in the table’s Fully Qualified Name (FQN): cartobq.docs.territory_balancing_milan_pos
.

Using H3 Spatial Indexes
The Territory Balancing component uses a graph partitioning algorithm that splits a gridified area into a set of optimal, continuous territories, ensuring balance according to a specified metric while maintaining internal similarity within each territory. To account for spatial dependencies when defining the graph, we rely on spatial indexes for efficiency and scalability: each node in our graph is defined by an H3 or Quadbin cell (white dots), with edges or connections (white lines) defined by their direct first-degree neighbours.

We'll map each restaurant to its corresponding H3 cell at resolution 9 and aggregate the data by cell. This will allow us to calculate the number of points of sale (POS) within each cell, along with the average popularity and sentiment scores. Use the H3 from GeoPoint and the Group by components to do so.

Balancing territories based on POS presence
Lastly, we will use the Territory Balancing component to obtain 9 continuous areas of equal (with a tolerance) number of restaurants so that workload is distributed evenly. We will select geom_count
(the number of restaurants) as the business KPI to be balanced, the so-called demand. We will also consider the average popularity and sentiment as similarity features, so that H3 cells within the same territory are similar in these metrics, while these averages differ across territories.

In the following map, we can see a comparison between a manual assignment based on administrative regions (Nuclei di Identità Locale, NIL) and an automatic one using territory balancing. The former is very unbalanced, with some territories being highly overloaded while others being assigned just a few restaurants. Using territory balancing techniques, it can be seen how territories are optimally assigned with balanced workload.
Last updated
Was this helpful?