Loading
CRM Analytics
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Filter and Selection Syntax for Embedded Dashboards

          Filter and Selection Syntax for Embedded Dashboards

          To specify filters or dashboard selections that require JSON strings, use the Filter attribute of the LWC CRM Analytics Dashboard component or the Filter String attribute of the embedded CRM Analytics Dashboard Aura component.

          Note
          Note You can use a token to pass a value from the parent page. If the token resolves to multiple values, the resolved values are properly reflected in the resulting filter string.

          Filter Syntax

          Use this syntax for filtering on dimensions. Example values syntax for measures and dates for both filters and selections follow further down.

          {"datasets" : {
              "dataset1": [
                {
                  "fields": ["field1"], 
                  "filter": { 
                      "operator": "in", 
                      "values": ["$value1", "$value2"]
                    }
                  }
                ]
              }
            }

          In this example, the dashboard filters the account name on the record page and shows only data related to that account name.

          {"datasets": {
              "account":[
                {
                  "fields":["Name"], 
                  "filter": {
                    "operator": "matches", 
                    "values":["$Name"]
                    }
                  }
                ]
              }
            }

          Selection Syntax

          With the selection option, the dashboard shows with all its data, and the specified dimension values are highlighted. The selection option can be used alone or with the filter option. Selection takes dimension values only. To use this option, the dashboard must include a query (step) of the specified id that groups by the specified group name. If a selection specifies a value that doesn't exist or if the query itself is unused (for instance, not attached to any widget), then the selection input is ignored and the dashboard appears with no selection applied.

          This example applies the account name as a selection. With the selection option, the dashboard displays all of its data, and the specified values appear highlighted or selected within the dashboard.

          {"steps" : {
              "Account_Step":  
                {
                  "metadata": {"groups": ["Name"]}, 
                  "values": ["$Name"]
                }
              }
            }

          Additional Filter and Selection Syntax Examples

          Use this syntax for filtering or selecting with measures values.

          {
              ...
              "values": [[value1]]
              ...
            }

          Use this syntax for filtering or selecting with relative date range values.

          {
              ...
              "values": [["year", 0], ["year", 2]]
              ...
            }

          Use this syntax for filtering or selecting with open-ended relative date range values.

          {
              ...
              "values": [null, ["year", 2]]
              ...
            }

          Use this syntax for filtering or selecting with absolute date range. Use epoch times for this range.

          {
              ...
              "values": [[1581033600000, 1585353600000]]
              ...
            }

          Syntax Reference Tables

          Use these tables to understand the notation for the filters and selection syntax.

          Notation Description Notes
          datasets The CRM Analytics datasets. Datasets have fields and a filter, described in the Datasets Notation table.

          Where to find it: In Analytics Studio, select Edit on the dataset. The System Name is in the left panel of the edit page for the dataset. If your org has namespaces, include the namespace prefix and two underscores before the dataset system name.

          steps The step names to reference for the selection. Steps have metadata and values, described in the Steps Notation table.

          Where to find it: In Analytics Studio, select Edit on the dashboard. Select the widget to apply the selection on. The step name is ID value on the Query tab.

          Datasets Notation Description Notes
          fields A list of Dimensions or Measures in the CRM Analytics dataset. Where to find it: Click the Explore icon to open the widget. Then select Show SAQL from the Options menu. For dimension names, look for “group by” statements. For measure names, look for statements with functions such as “sum” or “stddev.”
          filter The filter to apply to the dashboard data. Filters have operators and values, described in the Filter Notation table. The filter takes dimension or measure values, described in the next table.
          Filter Notation Description Notes
          operator The filter operator.

          Supported operators for dimensions: in, not in, matches

          Supported operators for measures: ==, !=, >=, >, <=, <

          values The values to use for the filter. These values can be statically specified or inserted dynamically from the page context using the $ prefix like $<FieldName>.

          Where to find it: In Setup, find the object you want, and select Fields. Use the Field Name, also known as the API Name. For custom fields, use the name with “__c” at the end.

          Steps Notation Description Notes
          metadata

          The step metadata.

          Any groups listed for the grouping must be referenced in the values.

          values

          The list of step values to use for the selection. These step values can be statically specified or inserted dynamically from the page context using the $ prefix like $<FieldName>.

          Where to find it: In Setup, find the object you want, and select Fields. Use the Field Name, also known as the API Name. For custom fields, use the name with “__c” at the end.

          Note
          Note The preceding syntax became available in Spring ‘17. The previous syntax remains supported, and it works the same as the new selection option. The new syntax is recommended for use, as it has better performance. For reference, here’s the previous syntax:
          { "datasetSystemName1": {"field1": ["$value1"]}, "datasetSystemName2": {"field1": ["$value1", "$value2"],"field2": ["$value3"]} } 

          For example:

          {"opportunity": {"AccountId': ["$Id"]}}

          Prevent users from exposing more data by locking or hiding filters. With the Locked option, the Filters menu appears in the embedded dashboard header, but users can’t modify or delete the filters. With the Hidden option, the Filters menu doesn’t appear in the embedded dashboard header.

          Locked and hidden options can only be used for filters and not for selections. Add the options in the filter’s JSON with a boolean value. For example, “locked”:false,”hidden”:true

          When setting up locked or hidden filters for embedded dashboards, keep in mind these considerations.

          • Locked and hidden filters are applied on the dashboard. If a filter makes a field visible, users see the field even when you’ve restricted access to filters with one of these options.
          • Locked and Hidden options aren’t automatically applied in linked dashboards or lens explorations. The options are applied only on the dashboard where specified.
          • Locked and Hidden options are applied to a dashboard when embedded or when opened in CRM Analytics Studio or Analytics tab.
          • When locked or hidden filters are applied to the dashboard, the My Views menu isn’t visible to users.
           
          Loading
          Salesforce Help | Article