Creating views

Last updated:

|Edit this page

In the PostHog data warehouse, you can save your most used queries as views and reference them in subsequent queries.

Creating a view

Query views are created directly inside SQL insights. If the query has valid view characteristics, the "Save as view" button is enabled. When clicked, you are prompted to give the view a name which can then be referenced in other queries.

For a query to be a valid view, all fields being accessed must be aliased (with the SQL as keyword). The alias names are how you access the fields on the view.

Note: Currently, nested views are not supported. You cannot create a view based on other views, only base PostHog models.

valid view

Extending PostHog models with views

Views are a powerful tool for extending existing PostHog models for easier data access. For example, if you wanted to associate your Stripe customer data with product usage data of your users, you would normally need to manually set up a join. With views, you can attach views to PostHog models so that you can directly access those fields on the PostHog table.

To link a view to a PostHog table, go to the data warehouse section, select the PostHog tab, and click "Link table to view." Select your tables, keys to join, and press save. Once done, when you query that PostHog table, you can access the data from your view.

view link

Questions?

  • Lucas
    3 months ago

    How to change the name of a view?

    How to change the name of a view?

  • Ulises
    7 months ago

    Cannot create view

    Hi Posthog team!

    I would like to first say that we are completely in love with your product so far. The switch from GA to Posthog has been super smooth and love all the functionality that you offer.

    What I'm trying to accomplish is basically an analysis where I can see which days of the week (Mon, Tue, Etc) have the most events. I created a view for it but I can't seem to be able to save it. Any ideas why? Capture.PNG

    • Asoka
      7 months agoSolution

      I got this error as well, after I removed the {filters} I was able to save as a view

Was this page useful?

Next article

Under the hood

There are two types of data sources we are able to connect data from—integrations we've built and custom sources you can link. Connectors Connectors use a combination of Temporal and the open source data loading tool, dlt to sync data from your source to PostHog's storage in S3. You can think of this as a complete extract and load tool where you simply provide the credentials and we will take care of the rest of the data flow. Custom sources The second option are custom sources. With custom…

Read next article

PostHog.com doesn't use third party cookies - only a single in-house cookie.

No data is sent to a third party.

Ursula von der Leyen, President of the European Commission