Creating Box Plot Insights
PostHogOfficialPublished by PostHog
- Skill
- Workflow
- Data and AI
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured workflow for generating box plot visualizations in PostHog. It helps users determine whether to use standard product analytics (Trends) or custom HogQL for their distribution data. The process covers data validation, insight creation, and verification to ensure that numeric distributions, quartiles, and medians are accurately represented.
What it does
- Determines the appropriate query method for box plot generation.
- Configures standard product analytics box plots using event properties.
- Constructs custom SQL queries for complex distribution analysis.
- Validates statistical data integrity for box plot components.
- Saves and verifies insights within the PostHog platform.
- Provides guidance on mapping SQL results to chart settings.
When to use it
- When you need to visualize the distribution of numeric data.
- When comparing medians or quartiles across different groups or time periods.
- When standard trend charts are insufficient and custom SQL aggregation is required.
- When you need to save a validated box plot insight to a PostHog project.
Advantages
- Ensures statistical accuracy by validating distribution data before saving.
- Offers flexibility by supporting both simple event-based and complex SQL-backed insights.
- Provides a clear verification step to confirm the insight is rendered correctly.
- Reduces errors in data visualization by enforcing specific SQL result shapes.
Usage examples
- “Create a box plot showing the distribution of latency_ms for the 'request completed' event over the last 8 weeks.”
- The agent will construct a SQL query to calculate min, p25, median, mean, p75, and max, then save it as a BoxPlot insight.
- “Build a box plot in PostHog to compare user session durations across different subscription plans.”
- The agent will identify the numeric property, configure the Trends query, and save the insight as a box plot.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/posthog/creating-box-plot-insights/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip creating-box-plot-insights.zip -d .agents/skills
Documentation by PostHog
Creating box plot insights
Box plots need distribution data, not an already-aggregated average or total. Choose the simplest query type that can express the user's question.
Choose the query type
Use a standard product analytics box plot when all of these are true:
The source is an event, action, or warehouse table supported by Trends.
One numeric property contains the values to distribute.
The user wants the distribution over a normal time interval.
Use a SQL box plot when the user needs custom grouping, joins, derived values, or bespoke SQL. Read querying-posthog-data before writing HogQL, then use references/sql-examples.md as a starting point.
Do not use SQL only to reproduce a standard Trends query.
Standard product analytics box plot
Identify the event or action and its numeric property. Confirm the property is numeric before saving.
Build an
InsightVizNodewhose source is aTrendsQuery:Set the series event or action.
Set
math_propertyto the numeric property.Set
trendsFilter.displaytoBoxPlot.Choose the date range and interval that match the question.
Run the query with
posthog:query-trends.If it returns distribution rows, save it with
posthog:insight-create.Read it back with
posthog:insight-getand confirm the property, interval, and display.
A box plot without a numeric math_property is invalid. Do not substitute event counts unless counts are the values the user wants to distribute.
SQL box plot
The SQL must return one pre-aggregated row for each X-axis and series pair. Calculate the summary in the database. Never calculate percentiles from the limited result rows in the client.
Required numeric roles:
minimum
25th percentile
median
mean
75th percentile
maximum
The easiest result shape uses these aliases:
x, series, min, p25, median, mean, p75, maxx and series are optional:
Set
xAxisColumntonullfor one overall distribution or one box per series.Set
seriesColumntonullfor one series.
Validate the HogQL with posthog:execute-sql before saving. Check that:
Every required statistic is numeric.
min <= p25 <= median <= p75 <= maxfor every row.The mean is between the minimum and maximum.
Each X-axis and series pair appears once.
There are at most 200 series and 10,000 X-axis by series cells.
Then save this shape with posthog:insight-create:
{
"query": {
"kind": "DataVisualizationNode",
"source": {
"kind": "HogQLQuery",
"query": "<validated HogQL>"
},
"display": "BoxPlot",
"chartSettings": {
"boxPlot": {
"xAxisColumn": "x",
"seriesColumn": "series",
"minColumn": "min",
"p25Column": "p25",
"medianColumn": "median",
"meanColumn": "mean",
"p75Column": "p75",
"maxColumn": "max",
"excludeOutliers": true
}
}
}
}Use the actual aliases when the query uses different names. Do not map the six statistics as six Y-axis series.
Verify the saved insight
Read the saved insight with
posthog:insight-get.Run it with
posthog:insight-query.Confirm the result still has the expected columns and one row per box.
Report the insight link, the numeric value being distributed, and the grouping choices.
If an individual row has a missing or invalid summary, PostHog omits that box while keeping valid boxes visible. Fix the SQL when omitted boxes are not expected.
Related skills
querying-posthog-data- required before authoring or changing the HogQL for a SQL box plot.formatting-insight-axes- use when the value axis needs currency, duration, percentage, or other formatting.building-a-dashboard- use when the box plot should be placed with other insights on a dashboard.
Files
- ATTRIBUTION.mdAdded by AutoGineer871 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md4.2 KiB
- references/sql-examples.md2.9 KiB
references/sql-examples.md
SQL box plot examples
Run each query with posthog:execute-sql before using it in an insight.
Deterministic sample data
Use this query to test the full SQL box plot flow without relying on project event properties:
SELECT
bucket AS x,
series,
min(value) AS min,
quantile(0.25)(value) AS p25,
quantile(0.5)(value) AS median,
avg(value) AS mean,
quantile(0.75)(value) AS p75,
max(value) AS max
FROM (
SELECT
concat('Week ', toString(modulo(number, 4) + 1)) AS bucket,
if(modulo(intDiv(number, 4), 2) = 0, 'Free', 'Paid') AS series,
toFloat(
modulo(number * 37, 100)
+ if(modulo(intDiv(number, 4), 2) = 0, 0, 20)
) AS value
FROM numbers(1000)
)
GROUP BY bucket, series
ORDER BY bucket, seriesMap xAxisColumn to x and seriesColumn to series.
Event property over time
Replace the event, property, and series expression with values from the user's project:
SELECT
toStartOfWeek(timestamp) AS x,
properties.plan AS series,
min(toFloat(properties.latency_ms)) AS min,
quantile(0.25)(toFloat(properties.latency_ms)) AS p25,
quantile(0.5)(toFloat(properties.latency_ms)) AS median,
avg(toFloat(properties.latency_ms)) AS mean,
quantile(0.75)(toFloat(properties.latency_ms)) AS p75,
max(toFloat(properties.latency_ms)) AS max
FROM events
WHERE
event = 'request completed'
AND timestamp >= now() - INTERVAL 8 WEEK
AND properties.latency_ms IS NOT NULL
GROUP BY x, series
ORDER BY x, seriesUse toFloatOrNull instead of toFloat when the property can contain non-numeric strings, then filter null values in an inner query before aggregating.
One overall distribution
Return one row and set both grouping fields to null:
SELECT
min(toFloat(properties.latency_ms)) AS min,
quantile(0.25)(toFloat(properties.latency_ms)) AS p25,
quantile(0.5)(toFloat(properties.latency_ms)) AS median,
avg(toFloat(properties.latency_ms)) AS mean,
quantile(0.75)(toFloat(properties.latency_ms)) AS p75,
max(toFloat(properties.latency_ms)) AS max
FROM events
WHERE
event = 'request completed'
AND timestamp >= now() - INTERVAL 30 DAY
AND properties.latency_ms IS NOT NULLUse:
{
"xAxisColumn": null,
"seriesColumn": null
}One box per series, without an X-axis
Return one row per series and set only xAxisColumn to null:
SELECT
properties.plan AS series,
min(toFloat(properties.latency_ms)) AS min,
quantile(0.25)(toFloat(properties.latency_ms)) AS p25,
quantile(0.5)(toFloat(properties.latency_ms)) AS median,
avg(toFloat(properties.latency_ms)) AS mean,
quantile(0.75)(toFloat(properties.latency_ms)) AS p75,
max(toFloat(properties.latency_ms)) AS max
FROM events
WHERE
event = 'request completed'
AND timestamp >= now() - INTERVAL 30 DAY
AND properties.latency_ms IS NOT NULL
GROUP BY series
ORDER BY seriesRequirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- PostHog
- Publisher
- PostHog (Official)
- Source
- PostHog/skills · skills/omnibus/creating-box-plot-insights · commit a5d30e7
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by PostHog or PostHog.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download creating-box-plot-insights.zip