---
schema_version: "1"
id: 21559b48b4e84aff124c34a62e1a7d54703bbc4041459ed37467afe2c7a2a2c9
title: Create Datasets from SOQL Queries
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/sales/264-0-0/territory_planning_data_sets_soql_queries.md
canonical_url: https://help.salesforce.com/s/articleView?id=sales.territory_planning_data_sets_soql_queries.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 9efc42b48a4016341d5de2fa03c1ef48b9d8f94bc9fd867413beda5cd372b825
description: Plan territories by specifying which Salesforce records to include in datasets by using SOQL queries that you write in Territory Planning.
products:
  - Sales Cloud
  - Sales Enablement
release: "264"
---
# Create Datasets from SOQL Queries

Plan territories by specifying which Salesforce records to include in datasets by using SOQL queries that you write in Territory Planning.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Professional</strong>, <strong>Enterprise</strong>, <strong>Performance</strong>, <strong>Unlimited</strong>, and <strong>Developer</strong> Editions with <a href="https://help.salesforce.com/s/articleView?id=sales.territory_planning_api_access.htm&amp;type=5&amp;language=en_US" target="_blank">Web Services API enabled</a></td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d30653e77">User Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d30653e77 ">To create datasets in Territory Planning:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d30653e77 ">
              <p>Sales Planning Ops Analyst permission set</p>
              <p>AND</p>
              <p>Query for Datapipelines User for Sales Planning permission set</p>
              <p>AND</p>
              <p style="margin-bottom:0;">SF Maps Territory Planning for Sales Planning permission set</p>
            </td>

          </tr>
        </tbody>
      </table>

1. To include high volumes of data into your datasets, turn on Bulk API. That way you reduce the likelihood of encountering Salesforce governor limits and speed up the loading process for alignments. Otherwise, skip to Step 2.
    
    From Setup, in the Quick Find box, enter Installed Packages, and then select **Installed Packages**. Next to the Salesforce Maps package, click **Configure**. Under Territory Planning, select **Data Management**, and then select **Bulk API**.
    
    Even with Bulk API turned on, Territory Planning validates SOQL queries using Apex.
2. In Territory Planning, click **Datasets**, then click **Create**. Specify whether you want to plan territories with live or copied data. Enter a name for the dataset and click **Next**.
    
    ![Option to create a dataset on the Datasets tab](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-sales-sales_performance_management-264-0-0-production-enus/b1f2feb4-26b8-444f-97f7-be2349869d93/sales_performance_management/images/salesforce_maps_territory_planning_data_set_create_1.png)
3. Click **Build Object Query**.
    
    ![Option to build a SOQL query](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-sales-sales_performance_management-264-0-0-production-enus/b1f2feb4-26b8-444f-97f7-be2349869d93/sales_performance_management/images/salesforce_maps_territory_planning_data_set_create_soql_1.png)
4. Give your query a name, then select an object.
5. Select the fields that you want to add or modify. To add field filters, select only the filters that include unencrypted fields. Avoid adding filters that include encrypted fields, such as those encrypted with Shield Platform Encryption.
    
    You can adjust the query directly. For example, use dot notation to pull fields from objects that the base object looks up to.
    
    ```sql
    SELECT ID, NAME, ANNUALREVENUE, BILLINGLATITUDE, BILLINGLONGITUDE, OWNER.NAME FROM ACCOUNT
    ```
    
    To join data from one object to another, specify custom relationships. For example, you plan territories for accounts and you want to relate custom territory information, such as territory IDs and names, to them.
    
    ![Query that relates territory information to accounts](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-sales-sales_performance_management-264-0-0-production-enus/b1f2feb4-26b8-444f-97f7-be2349869d93/sales_performance_management/images/salesforce_maps_territory_planning_data_set_create_soql_custom_relationship.png)
6. Test your query, then save your work.
7. Include the query that you created. Click **Next**.
    
    ![SOQL query that you created is available to include in dataset](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-sales-sales_performance_management-264-0-0-production-enus/b1f2feb4-26b8-444f-97f7-be2349869d93/sales_performance_management/images/salesforce_maps_territory_planning_data_set_create_soql_5.png)
8. Select a unit assignment field such as Owner ID. For more field options, turn on **Import Object Fields**.
    
    ![Object fields that you select for creating a dataset](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-sales-sales_performance_management-264-0-0-production-enus/b1f2feb4-26b8-444f-97f7-be2349869d93/sales_performance_management/images/salesforce_maps_territory_planning_data_set_create_soql_6.png)
9. Click **Finish**.

#### See Also

- [_Best Practices for Deployments with Large Data Volumes_: SOQL and SOSL](https://developer.salesforce.com/docs/atlas.en-us.salesforce_large_data_volumes_bp.meta/salesforce_large_data_volumes_bp/ldv_deployments_best_practices_soql_and_sosl.htm)
- [_Apex Developer Guide_: Execution Governors and Limits](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm)
- [How Shield Platform Encryption Works](https://help.salesforce.com/s/articleView?id=xcloud.security_pe_concepts.htm&type=5&language=en_US)