Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HogQL insight works with Dashboard filters #15999

Closed
timgl opened this issue Jun 12, 2023 · 6 comments
Closed

HogQL insight works with Dashboard filters #15999

timgl opened this issue Jun 12, 2023 · 6 comments
Labels

Comments

@timgl
Copy link
Collaborator

timgl commented Jun 12, 2023

Is your feature request related to a problem?

If I add a filter to a dashboard, or change the timeline, I want my HogQL insight to be filtered by that filter too.

Describe the solution you'd like

HogQL queries get filtered down. Either more explicitly by defining it:

SELECT * FROM events WHERE {event_filters}

or maybe just automagically?

Describe alternatives you've considered

Additional context

Thank you for your feature request – we love each and every one!

@timgl timgl added enhancement New feature or request team/product-analytics labels Jun 12, 2023
@mariusandra
Copy link
Collaborator

The first step towards this was done here: #15973

Regarding automagically, I'd love this to work, but our internal discussion concluded that this may be too tricky. E.g. subqueries to answer questions like "was this the first time the user performed $event" might have a longer time range than the "last 30 days" range the answers are calculated for.

Thus we'll at least need an opt out, such as SETTINGS ignore_dashboard_filteres=true at the end of the HogQL query.

However my vote goes for:

  1. Add the same row of filters (24h timerange + property filter) that are on dashboards into the SQL insight editing view.
  2. Add AND {event_filters} as part of the default query when you open the SQL insight tab. This would teach people about this feature, and how to make their custom insights "dashboard compatible".
  3. Update the HogQLQuery node to take an optional { event_filters: { properties, date_from, date_to } } parameter

@ithinkwong

This comment was marked as off-topic.

@putriapriandi
Copy link

for HogQL Table, I have already input it into the dashboard, but I cannot use the filters General available in the dashboard. Even though I have written the query as WHERE {filters}.

@Twixes
Copy link
Member

Twixes commented Jun 19, 2024

HI @putriapriandi, that doesn't sound right! Can you link to the insight here, so that we can investigate? (No worries, only us at PostHog will be able to do anything with this link)

@Twixes
Copy link
Member

Twixes commented Jul 9, 2024

Closing as I believe all insights should now work (let us know if that's not the case!)

@Twixes Twixes closed this as completed Jul 9, 2024
@abrambailey
Copy link

abrambailey commented Oct 23, 2024

Trying to query hog-managed mysql db.
{filters} -> Cannot use 'filters' placeholder in a SELECT clause that does not select from the events or sessions table.
{event_filters} -> Unable to resolve field: event_filters
{date_from} -> Unable to resolve field: date_from
{date_to} -> Unable to resolve field: date_to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants