---
schema_version: "1"
id: 896f775ec9611d052f33203f77653694929267873d6728056081bbf7b3064b46
title: Create a Custom Query with User-Defined Values
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/analytics/264-0-0/bi_dashboard_steps_custom_flex.md
canonical_url: https://help.salesforce.com/s/articleView?id=analytics.bi_dashboard_steps_custom_flex.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 5e243eec31ac9ca6298c062fc56b63c15360a9744105ef1f07bed2bc825dd279
description: "Use custom queries to apply user-defined values to dimensions, measures, and limits of other queries. For example, you can create a toggle widget that filters case records based on the following user-defined values: High Priority Cases, Medium Priority Cases, and Low Priority Cases. To enable these custom values to filter your data, you map them to your data using a binding."
products:
  - CRM Analytics
  - Cross Cloud
release: "264"
---
# Create a Custom Query with User-Defined Values

Use custom queries to apply user-defined values to dimensions, measures, and limits of other queries. For example, you can create a toggle widget that filters case records based on the following user-defined values: High Priority Cases, Medium Priority Cases, and Low Priority Cases. To enable these custom values to filter your data, you map them to your data using a binding.

![The dashboard contains a toggle widget with the following options: High Priority Cases, Medium Priority Cases, and Low Priority Cases.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_dashboard_static_step_widget_example.png)

1. To open the queries panel, click an empty space in the dashboard canvas in the dashboard designer.
    
    ![The steps panel shows the steps defined in the dashboard.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_dashboards_steps_panel.png)
2. Click **Create Query**.
    
    ![The Select a Dataset screen shows a list of all fields in the dataset.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_dashboard_widget_select_a_dataset_includes_static_option.png)
3. Click **Create Custom Query**.
    
    ![You can add custom values to the step in this modal.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_dashboard_step_static_custom_values_create.png)
4. Click ![pencil icon for editing](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_dashboard_custom_values_edit_pencil.png) to change the query label.
    
    CRM Analytics creates the query ID from the label. After you create the query, you can’t change the query ID. CRM Analytics refers to queries by their ID so dashboards don’t break if you change the labels.
    
    ![Add a dataset modal for measure or dimensions.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_dashboard_custom_choose_dataset.png)
5. Click **+Add Column** to add a dimension, measure, text, or number as a column to your custom query.
    
    1. For a dimension or measure, choose a dataset.
    
    ![Choose a field modall for measure or dimensions.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_dashboard_custom_choose_field.png)
6. Click **+Add** to add rows to your custom query.
    1. For a measure, choose a function. For a dimension or measure, choose a field.
        
        ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/images/icon_note.png)
        
        Note Each measure column in a custom query creates two values in the JSON. One value for the function (sum, average, etc.) and one for the selected measure field. Use both values when creating a compact-form binding on a measure.
        
        ![Add 2 extra columns for SAQL bindings to work](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_dashboard_custom_SAQL_columns.png)
7. Add up to 20 columns and click **Done**.
    
    ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/images/icon_note.png)
    
    Note To create SAQL bindings, your custom query requires two additional text columns. One column determines the value of the field and the other column is for the field label.
    
    CRM Analytics adds the query to the query panel, making it available for use by other widgets in the dashboard.
8. To make changes, find the query in the query panel, click ![pencil icon for editing](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_dashboard_custom_edit_button.png), then **Edit**.
    
    You can change the query name, add and remove columns, add row and column values, reorder columns, and pick values from a dataset.
    
    ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/images/icon_note.png)
    
    Note To use a custom query for linking, make the column the first column in the dialog.
9. To apply this custom query to a list or toggle widget:
    1. Drag the list or toggle widget from the widget toolbar to the dashboard canvas.
    2. Drag the custom query on top of the widget.
        
        The widget shows the custom display values as selection options.
    3. To change the widget and query properties, select the widget.
        
        The Widget panel groups the widget properties into sections. So that you don’t accidentally overlook any properties, expand any collapsed sections.
    4. To customize the appearance of the widget, set the widget properties.
    5. To preview your changes to the dashboard, click ![Preview button](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_icon_preview_dashboard.png).
    6. Save the dashboard.

If you applied the custom query to a list or toggle widget, you can see the widget in the dashboard. To specify how a selection in this query affects other widgets, bind the values of the custom query to other widgets. For example, create a binding that filters the other widgets based on a value in the list or toggle widget. For more information about binding queries, see the [CRM Analytics Interactions Developer Guide](https://developer.salesforce.com/docs/analytics/bi-dev-guide-bindings/guide/bi-dbjson-bindings.html) .

#### See Also

- [Query Properties for Analytics Dashboard](https://help.salesforce.com/s/articleView?id=analytics.bi_dashboard_step_properties_flex.htm&release=264.0.0&type=5 "Query properties define the query that returns results to display in the widget. These properties also specify how the widget behaves and interacts with other widgets in the CRM Analytics dashboard. The properties apply to dashboards created in the dashboard designer only.")
- [Widget Properties for Analytics Dashboard](https://help.salesforce.com/s/articleView?id=analytics.bi_dashboard_widget_properties_flex.htm&release=264.0.0&type=5 "Widget properties define how widgets appear in the Analytics dashboard. For example, you can apply labels, backgrounds, and borders. To make widgets look consistent, you can set up default widget properties in the layout and then assign them to each widget. Widget properties vary based on the widget type and the designer used to create them. The properties listed here apply only to widgets created in the dashboard designer.")