Advanced Reporting Creating Metrics and Filters 2
Building filters to filter data on reports
A filter screens data from your data source to determine whether the data should be included in, or excluded from, the calculations of the report results. Filters are helpful in reducing large quantities of data and only displaying pertinent subsets of that data, so the reports show you what you really need to see.
Filter Examples
If you are familiar with SQL syntax, it may help to know that a filter is equivalent to the
WHERE clause in a SQL statement.
Applying filters to reports allows you to reuse the same report with different filters to achieve different results, tailored to a specific scenario or business question to be answered. For example, consider the following diagram, which shows a table of data filtered by three different report filter conditions:
Filter Conditions
© 2017 MicroStrategy, Inc.
Building filters to filter data on reports
41
2
Creating Metrics and Filters Advanced Reporting
As you can see, each report filter condition returns a different result set. You need to know how to design the correct report filter to retrieve the desired data.
You can create:
•
Report filters: Are used in the SQL that is generated to retrieve the report results from the data source. Report filters can use any object in the project, whether or not it is part of the report.
•
View filters: Are applied to the report results after the SQL is executed and the results are returned from the data source. View filters do not modify what data is retrieved from the data source. This can help improve report execution performance. A view filter is created on the fly in a report, based only on those objects that exist in the Report Objects pane.
The advantage of using both report filters and view filters on a report is that the report can use the report filter to bring back more data than can usefully be displayed at any one time. An analyst can then use a view filter to change which data is displayed. A view filter does not trigger re-execution against the data source. This capability translates to improved response time and decreased database load.
Limiting data displayed on the report: View filters
Once a report is displayed, you can narrow its results by creating a view filter and applying it to the report. The view filter restricts data based only on the report results already displayed on the screen.
View filters are created within a report, based only on the objects in the Report
Objects pane. A view filter dynamically limits the data being displayed on a report without re-executing the report against the data source. This feature allows analysts to create multiple reports out of a larger parent report, without stressing the system or your data source. This can help improve report execution performance. It also allows different users to access the same report cache but see different data according to their needs.
The View Filter pane allows you to create conditions for the view filter. A condition defines what the data must meet to be included on the report. The View Filter pane also displays the view filter conditions that are applied to your report.
View Filter Pane
42
Building filters to filter data on reports © 2017 MicroStrategy, Inc.
Advanced Reporting Creating Metrics and Filters 2
Exercise 2.2: Create a view filter
We will create a view filter to restrict an existing report to the Music and Movies categories, with profit values less than $3000. This exercise uses both an attribute filter (on Category) and a metric filter (on Profit).
Open the report
1 In the MicroStrategy Tutorial project, click the Shared Reports icon
.
2 Click Subject Areas, then Sales and Profitability Analysis, and click the report named Revenue and Profit Trends by Region, Category, and
Quarter to run it.
3 Drag Region from the Page-by pane to the left of Category on the report grid.
Removing the page-by is not a requirement for creating a view filter. In this example, it provides another attribute on the report grid, and allows us to focus on how view filters affect the report results.
4 The resulting report looks like the following. Notice that the report filter and page-by are both blank now. The report contains 338 rows. Take note of the profit value for Central, Movies, 2013 Q4, which is $2,370. This will help us
© 2017 MicroStrategy, Inc.
Building filters to filter data on reports
43
2
Creating Metrics and Filters Advanced Reporting monitor if and how metric values change when we create and apply the view filter.
Create a view filter
1 From the Tools menu, select View Filter, to open the View Filter pane.
2 In the View Filter pane, click Add Condition.
Data must meet the defined condition to be included on the report.
3 From the Filter On drop-down list, select Category.
44
Building filters to filter data on reports © 2017 MicroStrategy, Inc.
Advanced Reporting Creating Metrics and Filters 2
The Filter On list contains only the objects on the report.
4 By default, a view filter on an attribute allows you to create a list of the attribute elements to include in the report. You can instead use the list to exclude elements (by selecting Not in List). For this example, keep the operator as In List, and add Movies and Music to the list.
•
The elements of an attribute are the unique values for that attribute. In this case, the attribute is Category, and its elements are Books, Electronics, Movies, and Music.
•
Instead of creating a list, you can create a qualification, which compares the attribute to a specific value. You will create a qualification using a metric later in this exercise.
5 Click Apply. The view filter is applied to the report data, and only data for the
Movies and Music categories is included on the report. The View Filter pane now displays the condition that you created.
The number of rows has decreased from 338 to 178, but the data values have not changed.
•
The number of rows has decreased because only half the categories are now included on the report.
© 2017 MicroStrategy, Inc.
Building filters to filter data on reports
45
2
Creating Metrics and Filters Advanced Reporting
•
The calculations are not affected by the view filter; the view filter affects what data is displayed. For example, the profit value for Central, Movies,
2013 Q4 is $2,370, the same as in the unfiltered report.
Add another condition to the view filter
6 You want to further focus your analysis, to identify categories with a low profit.
Click Add Condition in the View Filter pane.
7 From the Filter On drop-down list, select Profit.
8 Select Less Than from the list of operators.
9 Type 3000 in the value box.
10 Click Apply. The view filter is applied to the report data, and only data for the
Movies and Music categories that have profit values below $3000 is included on the report. The View Filter pane now displays both conditions that you created.
The number of rows has decreased from 178 to 132, but the data values have not changed.
•
The number of rows decreases because the quarters that have more than
$3000 profit are no longer displayed on the report. For example, the row for Central, Movies, 2013 Q1 is no longer displayed (its profit was $4,083).
46
Building filters to filter data on reports © 2017 MicroStrategy, Inc.
Advanced Reporting Creating Metrics and Filters 2
•
Since the view filter affects what data is displayed, the calculations are not affected by the view filter. The profit value for Central, Movies, 2013 Q4 is
$2,370, the same as in the previous reports.
Save the report
1 Save the report in the My Reports folder as View Filter, and close the report.
Limiting the data retrieved from the data source: Report filters
You can create a report filter:
•
When you create the report, dynamically. The difference between this type of report filter and a view filter is that you can use any object in your data source, whereas a view filter uses only those objects on the report. When you create a report filter this way, it is saved within the report and cannot be used on other reports.
•
As a stand-alone object. The object can be used on multiple reports, as well as other objects, such as metrics. This saves time—you can create one filter and use it in multiple objects, instead of creating a filter on each object.
In Design Mode, a dynamic report filter displays the filter definition, while a stand-alone filter displays its name. In the example below, the stand-alone filter is
© 2017 MicroStrategy, Inc.
Building filters to filter data on reports
47
2
Creating Metrics and Filters Advanced Reporting named Movies & Music, while the dynamic report filter uses the Subcategory attribute in its definition.
Filter types
A filter is composed of at least one qualification. A qualification defines the condition that the data must meet to be included in a report, for example,
“Region = Northeast” or “Revenue > $1 million”.
You can create the following types of filter qualifications:
Filter Type Description
Attribute Qualification: Restricts data based on attributes
Example
Attribute element list qualification
Attribute form qualification
Filter based on attribute elements, such as North, South, and West for Region attribute
Filter based on attribute forms, such as the ID or description
(which is the name) of the
Customer attribute
Region In List North, South, and
West
•
Customer Description Begins
With SMITH
•
Customer ID = 001 - 100
•
Ship Date between 1/1/2016 and 6/30/2016
Set Qualification: Create a subset of attributes, generated dynamically based on the metrics associated with those attributes or the relationships between those attributes.
Metric qualification Filter based on a metric’s value, rank, or percent
•
Revenue > 300,000
•
Rank of Profit = 1
Relationship qualification
Filter based on relationships between two attributes
Stores selling Nike shoes in the
Northeast (relationship between the Item and Region attributes)
Shortcut qualifications: Restrict data related to an existing report or filter.
48
Building filters to filter data on reports © 2017 MicroStrategy, Inc.
Advanced Reporting Creating Metrics and Filters 2
Filter Type
Shortcut-to-a-report qualification
Shortcut-to-a-filter qualification
Description
Filter based on the results from an existing report, with additional qualifications, if needed
Example
The intersection of the 1/1/2015
Active Customers report and 12/
31/2015 Active Customers report to display continuing customers
Filter based on an existing filter, with additional qualifications, if needed
Add a qualification to determine active customers to the Region In
List North, South, and West filter described above
You can also create advanced qualifications such as attribute-to-attribute qualifications and prompted filters. For more information on all types of advanced filters, refer to the Advanced Filters chapter of the MicroStrategy Advanced Reporting
Guide. This course will discuss most of the filter types listed above; relationship qualifications are presented in the Advanced Analytics class
© 2017 MicroStrategy, Inc.
Building filters to filter data on reports
49
2
Creating Metrics and Filters Advanced Reporting
50
Building filters to filter data on reports © 2017 MicroStrategy, Inc.