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 however 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
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.
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.