If you have a comment on this topic, contact Aptify Documentation. If you want to return to the Aptify Community Site, please click here.

Filtering Based on Multiple Topic Codes

When you create a view that references another service, Aptify generates the necessary SQL automatically to retrieve the desired information. For the sake of efficiency, Aptify generates a single sub-query for all filter statements that apply to the related service.

This approach is suitable in most cases, although under some circumstances, your view may return no records if the filters you specified are mutually exclusive. Consider the following example:

A user wants to create a view that returns the Persons who are linked to both the Business and Languages topic codes. To that end, the user creates the following filter statements for a view in the Persons service and uses the default AND operator to connect them:

  • Filter Statement 1:
    • Service: Topic Codes
    • Field: Topic Code
    • Operator: Exactly Matches
    • Value: Business

  • Filter Statement 2:
    • Service: Topic Codes
    • Field: Topic Code
    • Operator: Exactly Matches
    • Value: Languages

Multiple Topic Code Filters
However, this view will return no results because the viewing system generates a single sub-query for both statements: there is no single Topic Code Links record that is linked to both topic codes.

 Generated SQL Statement with Single Sub-Query

To specify that you want the system to generate a separate sub-query for each filter statement, enclose each filter statement in parentheses within the Filter Logic area, as shown in the following figure.

Enclosing -Filters in Parentheses

This automatically generates a new SQL statement that uses two sub-queries to identify topic code relationships. When loaded, this view returns the desired results: the list of Persons who have attended both the Business topic code and the Languages topic code checked.


Generated SQL Statement with Two Sub-Queries

Copyright © 2014-2019 Aptify - Confidential and Proprietary