Start tracking your progress
Trailhead Home
Trailhead Home

Build Dynamic Top-N Queries and Add a Greeting

Top-N filters give users limiting options when viewing the number of rows in a dashboard. For example, you can have a top 10, 20, and 50 button. When you click 10, the dashboard dynamically reduces the number of items you see to the top 10. This is ideal for making your dashboard readable and giving users the power to manipulate it in a way that suits them.

In this step, you create a Top-N toggle that dynamically filters the chart widget. Then, you set up a fun greeting to make the dashboard even more personal.

Set up a Query Limit

First, set up a placeholder query limit.

  1. Double-click the column chart on the dashboard.
  2. Click Charts iconto open the Charts options.
  3. Select Bar.
  4. Click the Close Date bar.
  5. Click the back arrow to select a group.
  6. Search for and select Opportunity Name.
  7. Click the down triangle on Sum of Amount to open sorting options.
  8. Select Sort Descending.
  9. Scroll down to Query Limit and click Edit.
  10. Enter 20 and click Apply, then click Update.

Create a Top-N Toggle

Create a toggle with Top-N values.

  1. Click an empty area of the dashboard, then click Create Query.
  2. Click Create Custom Query.
  3. Type in display values:
    1. 10
    2. 20
    3. 50
  4. Add a Number column with 10, 20, and 50 to correspond with the Display values. Toggle display and values.
  5. Click Done.

Add the Toggle to Your Dashboard

Add a toggle to your dashboard.

  1. Drag a Toggle widget to just above the bar chart.
  2. Drag the static_# lens into the widget. The hashtag (#) represents the numeric suffix added to your query.
  3. Resize the toggle to the length of the bar chart. Toggle widget.
  4. Click the toggle widget.
  5. Now, click the Query tab.
  6. Under Selection Type, select click Single selection (Required) from the dropdown menu.

Set Up a Dynamic QueryBind 

Bind the toggle to the bar chart.

  1. Click the bar chart.
  2. Click the Advanced Editor button.
  3. Click the Query tab.
  4. Under Source Query, select static_#.
  5. Click Source Datathen make the following selections:
    1. Data selection: Cell
    2. Row Index: 0
    3. Column: Number2
  6. Click the back arrow next to Select Data.
  7. Under Interaction Type, click Selection.
  8. Next, expand More Options and confirm Data Serialization Functions is asString.
  9. Click the Copy button in the CREATED INTERACTION section of the page.
  10. Then, click a line in the query and search for "limit".
  11. Replace the limit value by pasting the copied code.
  12. The limit value should now look similar to this:
    "limit": "{{cell(static_1.selection, 0, \"Number2\").asString()}}"
  13. Click Save and save the dashboard.

Test the Dashboard

  1. Preview the dashboard by clicking Preview(e) icon .
  2. Change the Opportunity Owner list widget to All.
  3. Click each of the values in the toggle to test. Notice the amount of opportunities that show up correspond to the value you choose. Dashboard toggle dynamically updating widgets.

Create a Customized Greeting

Remember, you have the LoggedInUser query that holds the logged-in user information. You use it to create the greeting.

  1. Put the dashboard in edit mode by clicking edit(e) icon .
  2. Add a text widget under the dashboard headline. Move the headline up if the text widget doesn't fit.
  3. Enter Hello, in the widget’s Text property. Hello, added to text widget.
  4. Click Add Query Data.
  5. Click Select Query and select LoggedInUser_#.
  6. Now, click the Select Field dropdown menu and select Name.
  7. Confirm Interaction Type is Result.
  8. Click Done then save the dashboard.
  9. Preview the dashboard. Personalized dashboard with logged in user greeting.

Well Done!

You created intelligent dashboard interactions and customizations with minimal coding. Now that you know what’s possible with the Advanced Editor, feel empowered to create SOQL queries and complex bindings.

Resources