Start tracking your progress
Trailhead Home
Trailhead Home

Filter an Embedded Dashboard

Construct a Dashboard Filter

Creating a separate opportunities dashboard for each account can be… well, let’s just say that it doesn’t scale well.

Instead, you can use a filter to make an embedded dashboard show only the data that applies to the current record. Think of it as a chameleon that matches its surroundings.

To create your filter, you must know the API name of your dataset and the names of the fields you want to match.

  1. Click the App Launcher, and then click the Analytics Studio tile.
  2. In Analytics Studio, click the DATASETS tab. You see a list of all datasets.
  3. On the right end of the row for DTC Opportunity, click the menu button, and click Edit.
  4. On the DTC Opportunity dataset page, you see its API name: DTC_Opportunity_SAMPLE. Make a note of the name.
  5. In the upper right, click the Explore button. A new tab opens and shows a new lens.
  6. On the left, next to DTC Opportunity, click Fields.
  7. Select Show Field API Names.
  8. In the Dimensions list, find Account Name. Make a note of the API name of the field: Account_Name.
  9. Close the New Lens and Dataset tabs.

To learn the API name of the account-name field in the Account object, you can use the Salesforce Developer Guide. The Account page in the SOAP API Developer Guide reveals that the API name is, quite logically, Name.

You now have all the pieces you need for your filter.

Element API Name
Dataset DTC_Opportunity_SAMPLE
Account name field in Opportunity object Account_Name
Account name field in Account object Name

This is as far as “clicks, not code” can take you for now. Time to make a short foray into code land!

A filter is written in JSON, which associates a name and a value by placing a colon between them and then wrapping them in braces or brackets. For example, if you want to associate a name of city with a value of New Orleans, the JSON looks like this: {'city': 'New Orleans'}.

The challenge is the syntax of a filter. It’s picky. Get one character wrong, and it doesn’t work the way you want.

We won’t make you build your first one from scratch, though. Here’s the entire filter:

{'datasets': {'DTC_Opportunity_SAMPLE': [{'fields': ['Account_Name'], 'filter': {'operator': 'matches', 'values': ['$Name']}}]}}

See some familiar names in there? In English, you can read it like this:

“In the dataset named DTC_Opportunity_SAMPLE, show only the records in which the Account_Name field matches the Name field.”

Let’s put it to work.

Add a Filter to an Embedded Dashboard

If you’re not already looking at an account page, follow these steps.

  1. Close the Einstein Analytics tab in your browser.
  2. In the navigation bar of the Sales app, click the down arrow on the right of the Accounts tab.
  3. Click All Accounts.
  4. In the Account Name column, click any account name, such as Abbott358 Inc.

Add the filter to the embedded Opportunity Details dashboard.

  1. In the account page, click the Setup icon at the upper right, and then click Edit Page.
  2. Click anywhere in the Opportunity Details dashboard.
  3. In the properties list on the right, enter the following JSON string into the Filter field. (We recommend copying and pasting, but that’s up to you.)


    Location of Filter field in properties list
  4. Click Save in the upper right.
  5. To return to the account page, click Back in the upper right.

Depending on the account you selected, the Opportunity Details dashboard might or might not show any data. The Abbott358 Inc account, for instance, has no open opportunities, so the only interesting number is the total for won opportunities (98.9K).

You can prove that you’re looking at only the opportunities for Abbott358 in the dashboard: Click in the Account filter. You see that the only account listed is Abbott358 Inc.

Let’s look at something a bit more interesting.

  1. In the Search Salesforce box at the top of the page, type Fowler322.
  2. In the search results, click the entry for the Fowler322 Inc account.

The Opportunity Details dashboard shows one open opportunity. In the Stage section, you can click Won to see three won opportunities. (This account has five opportunities in total. You can see all of them by scrolling down to the Opportunities section of the page.)



The sample dataset doesn’t contain many opportunities. In real life, you’d probably see a lot more.

You can select any account page, and the embedded dashboard now filters its data to show only the opportunities associated with that account. A sales rep can quickly see which opportunities are the most promising to pursue. Or the VP of Sales can check the open opportunities for an account and see at a glance how they’re progressing.

Go Beyond Analytics Embedded in Salesforce

Embedding a dashboard in a Lightning Experience page and adding a filter are just the start to making Analytics dashboards and their data insights available everywhere. Consult the resources listed at the end of this project to learn more about advanced embedding and integrating technologies.