Overview
This example demonstrates how to filter the output of insights by applying a filter.
It is based on the same example as in Example: Create an insight with metrics โ the Total monthly sales insight. It builds on it to include the filter.
The original insight sums the revenue of all sales opportunities that are won. This example introduces a filter. You can use the filter to filter which sales opportunities, you want to filter. For example, you may want to see what is the total amount of sales that are in progress.
To accomplish this, you first create the filter, then, include it in the insight, and, finally, use it on the insightboard to filter the data.
The example uses the List filter. This is a filter where you can select one option from a predefined list of options.
For more information, see Create filters for insightboards.
Prerequisites
To create this example, you must have first created the insight in Example: Create an insight with metrics.
Create the filter
Perform the following:
In the bottom of the navigation pane, click Settings.
On the Configuration tab, click Insightboard parameters.
Click ADD NEW PARAMETER.
In Title, enter Status filter
In Key, enter status_filter
In Selector, select List.
Under Dynamic values, move the toggle switch to Use connected entity values.
In Entity type, select sales_monthly.
In Title field, select Status of deal.
In Value field, select Status of deal.
Click Create insightboard parameter.
Edit the Total monthly sales insight
Perform the following:
In the navigation pane, expand Insights and click Insightboards.
In the toolbar, click Manage insights.
Find the Total monthly sales insight and expand its menu.
Click Edit insight.
Edit the SQL to include the filter
The SQL editor, enter the following query:
SELECT SUM(sale_rev) as total_won
FROM sales_monthly
WHERE
CASE WHEN '%%status_filter%%' <> ''
THEN sale_stage = '%%status_filter%%'
ELSE false END
Do not change the HTML of the insight and click Save and leave.
For more information, see Sample filter syntax and Create insights with SQL.
Apply the filter
The filter is created and you can apply it on the insightboard.
Perform the following:
Navigate to the insightboard that contains the insight.
In the toolbar, you can see the new filter.Click the filter, select in progress, and click Apply selection.
The output of the insight changes to $2,000.00.To save the filtering, click Save filters.
For more information, see Filter the output of insights.