MicroStrategy ONE
Supporting Grid/Graph Filtering for Document Datasets Based on Large XQuery Reports
Report Services document designers can enable Grid/Graphs as report condition selectors to filter the data in a dataset, allowing users to view subsets of large amounts of data, rather than loading and displaying all the data at once. For standard reports in MicroStrategy, this dataset filtering is automatically supported by re-executing the underlying report definition for a dataset.
An example of using dataset filtering to view subsets of data is described in Reporting Analysis Features.
If your dataset is based on a large XQuery report, a static XQuery statement cannot automatically be updated to reflect this type of filtering. You must define the XQuery report to apply this filtering in the XQuery definition, by inserting a condition placeholder into the XQuery statement. The steps to add a condition placeholder are described below.
To Add a Condition Placeholder to an XQuery Statement
- In MicroStrategy Developer, navigate to your XQuery report.
- Right-click the report, and select Edit.
- Choose Data > Freeform SQL Definition.
Typically, the placeholder is added before the
return
statement in XQuery.An XQuery report retrieves user data using a
for
loop, shown in the code fragment below:<Data>
{
for $ancestor0 in $ancestor/users/user return
<Row> <first-name>{fn:data($ancestor0/first-name)}</first-name></Row>
}
</Data>
In this case, the condition should be inserted before
return
, at the end of thefor
statement. - In the XQuery statement, right-click the location where you want to insert the condition placeholder, and click Insert Condition. The Define Conditions dialog box opens, shown below.
- Next to the Attribute field, click ... (Browse button).
- Select the attribute to use in the report's filter, and click OK.
If you want analysts to be able to filter results by a customer's first name, select First Name.
- In the Optional Text field, enter the XQuery syntax to filter the report.
The syntax to filter results by the First Name attribute is as follows:
where fn:data($ancestor0/first-name) = "[First Name]"
- If the XQuery report for the dataset should only be executed when a selection is made using the separate report condition selector, enable the Condition is required for execution check box.
- Click OK.
- In the Freeform SQL Editor, click OK.
- Save and close the XQuery report.
This condition placeholder is dynamically generated whenever a user makes a selection using a separate report condition selector.