Filters

Last updated:

|Edit this page

Trends support two types of filters:

  1. Inline filters – only apply to a specific series in your insight.
  2. Filter groups – global filters that apply to the whole insight.

Inline filters only support AND operators – i.e. all filter conditions must be met for an event or user to be included.

Filter groups support AND and OR operators – i.e. events will be included if one or both of the filter conditions are met.

Configuring filters

Filters are comprised of three elements, a property, an operation, and a value.

Note: You can also fully customize your filter by writing them as a HogQL expression. See our tutorial on using HogQL for advanced time and date filters for an example.

1. The filter property

Example: (Current URL, Browser, etc)

This is the property that you want to filter based on. These properties can be:

  • Properties on the event itself
  • Properties on the person who sent the event
  • Properties on groups that this event is a member of (see group analytics)
  • Properties on sessions
  • Properties on cohorts the user is a member of
  • Properties on the HTML element if an event was autocaptured

By default, the dropdown will only show properties that have been seen on a specific event before, but if you instead want to filter based on an unseen property, you can scroll all the way to the bottom of the list and click 'Show X properties that haven't been seen with this event'

2. The filter operation

Example: (equals, contains, etc)

This is what PostHog uses to compare the property value to determine whether an event passes the filter or not. Note that the options for this will change based on the type of the property you've selected (e.g. whether a property is a Number or String).

NameDescription
= equalsThe property matches the value exactly and can contain multiple values to match against
≠ doesn't equalThe property doesn't exactly match any of the values you provided
∈ containsThe property contains the value as a substring
∉ doesn't containThe property doesn't contain the values as a substring
~ matches regexThe property matches a regex (only available for strings)
≁ doesn't match regexThe property doesn't matches a regex (only available for strings)
> greater thanThe property is greater than a specific value (only available for numeric properties)
< less thanThe property is less than a specific value (only available for numeric properties)
✓ is setThe property was not set on a specific event
✕ is not setThe property has been set on a specific event

3. The comparison value

This is the value that PostHog compares to the property using the operation you specified. If the operation returns true, then the event is included in the insight, and if it returns false it is excluded.

Some operations allow you to pass multiple values to compare against, in which case the event is included if any of these values return true when compared.

Types of filters

Inline filters

Example inline filter

These filters apply to a specific series within a graph. You can apply totally different filters to each series in a trends insight.

To add a filter to a series, click the icon next to the event name, and search for your desired property.

Currently, inline filters only support with AND operations. If you want to include events that match at least one of a group of filters – i.e. OR operations – use filter groups.

Filter groups

Filter groups allow you to apply filters to all series within an insight. These filter groups are composed of a number of single filter, which can be combined in the following two ways:

  • AND - Events have to match every filter within the group
  • OR - Events only have to match a single filter within the group
Example global filter

Click the + Add filter group button to add a filter group. You can add multiple filter groups and you can use AND OR operators both within and between filter groups.

Important: Since group filters apply to all events within an insight, and these events may not share all their properties, group filters permit you to use any property that has been seen in at least one of your events. If you happen to create a filter that references a property that not all events have, events that do not contain this property will automatically fail the check and will be excluded by the filter.

Filtering internal and test users

The final option for filtering events is using the option to filter out 'internal and test users'.

This option is useful for excluding events sent from local builds of your product, or by members of your team that you don't want to include in your analysis.

Filtering internal and test users turned on

Click on the settings icon to go to your project settings to customize the filters that are used.

Questions?

Was this page useful?

Next article

Aggregations

There are numerous ways to aggregate events and properties in trends, so you can go beyond just tracking the total number of events. Aggregations enable you to answer questions like: What is the average session duration of users on my site? How many unique users have used a feature within the last month? What is the 95th percentile in time spent loading? How often do users perform a specific event or action? How do power users and a non-power users behave? Event aggregation Event aggregation…

Read next article