You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

It is recommended to get familiar with filter function before proceeding with this tutorial.

You can set up filters for view in Filter dialog.

Sometimes it is more convenient to add filter directly to indicator formula. You can do this when:

  • you are cross referencing data from other data sets.
  • you do not want your users to change filters.

Filtering Attributes

The filter function supports most of the operators supported by PostgreSQL such as in/not in, ilike, like/not Like, similar to/not similar to etc. "ilike" is similar to "like" but case insensitive to the pattern matched.

  • Filter using operator: in/not In

Following example filters data to include only Paris, Berlin and London in their City attribute. Result returns aggregation of visits in these three citites.

filter("L_CITY in ('Paris','Berlin','London')") {
    return M_VISITS;
}

Note the correct usage of apostrophs in the example.

  • Regular Expressions

Pattern

Description

_

Stands for any single character.

%

Stands for any sequence of zero or more characters.

*

Denotes repetition of the previous item zero or more times.

+

Denotes repetition of the previous item one or more times.

?

Denotes repetition of the previous item zero or one time.

{|

Denotes alternation (either of two alternatives).

Some examples for regular expressions:
'abc' LIKE 'abc'    true
'abc' LIKE 'a%'     true
'abc' LIKE '_b_'    true
'abc' LIKE 'c'      false

Filtering Indicators

Following example counts number of records which have Indicator's value of visits greater than 3.

count = 0
filter('M_VISITS > 3') { 
    count++; 
} 

return count;

Note that filter is applied on every record and not on its aggregated value displayed in the view.

Multiple Filters

Following example returns number of students who had Exceptional results from Math subject.

filter("L_PASS_RESULT in ('Exceptional')) AND (L_PASS_SUBJECT in ('Math')"){
  L_STUDENT_COUNT
}

You can combine multiple filter conditions with AND or OR conjunction.

Next Steps

  • No labels