table-calculations
What it does
This skill explains how to write table calculations for Lightdash metric queries. It is for analysts who need comparisons, percentages or rankings on top of query results.
When to use it
- ✓When you need a ratio or percentage of total in a Lightdash query.
- ✓When you want a running total, moving average or ranking of results.
- ✓When you need a period-over-period change or the top items in each group.
Skill link
https://github.com/lightdash/lightdash/blob/main/packages/backend/src/ee/services/ai/skills/builtInSkills/table-calculations/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“In my Lightdash query of monthly revenue, add a column with the running total and a column with the change from the previous month.”
5 new skills a week. 1 minute to read.
How it works
The skill explains the spreadsheet-style formula syntax used by table calculations. It shows how to reference selected fields and other calculations, and how to use the formatting options for percentages.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Table calculations
For run_metric_query, author queryConfig.tableCalculations as type formula. The input schema documents the syntax and required fields; use spreadsheet-like formulas, not raw SQL.
Calculations operate on query results after aggregation. Reference selected field IDs or other table calculation names. The names below are placeholders: replace them with the actual fields or calculations in your query. Do not add grouping dimensions unless the user requested that grain.
When to use them
- Arithmetic across metrics:
metric_a + metric_b, ratiosmetric_a / metric_b. - Aggregating already-aggregated metrics (e.g., average of monthly totals):
AVG(metric). - Percent of total:
m / SUM(m). - Period-over-period:
(m - LAG(m, ORDER BY date)) / LAG(m, ORDER BY date). - Rankings:
RANK(ORDER BY m DESC). - Running totals:
RUNNING_TOTAL(m, ORDER BY date). - Trailing 3-period average:
MOVING_AVG(m, 2, ORDER BY date). The second argument counts preceding rows; the current row is also included. - Top N per group:
ROW_NUMBER(PARTITION BY group, ORDER BY m DESC), then filter on that calculation.
Use the schema's formatting options for ratios and percentage changes; do not multiply a fraction by 100 when using percent formatting.
FAQ
Are table calculations SQL?
No, they use spreadsheet-like formulas that work on the query results, not raw SQL.
Will they change the grouping?
No, they work on the results and do not add grouping fields unless you ask for them.
How do I show a percentage?
Use the formatting options for percentages instead of multiplying by 100.
Details
Original description by the author
Author formula table calculations for run_metric_query, including ratios, aggregate comparisons, windows and rankings.
repo: lightdash/lightdash
Popularity
- GitHub stars
- 6.2k
- Ranking position
- #14401
- License
- —
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
breakup-pr
6.2kHelps your agent split a large pull request into smaller, stacked slices that can be reviewed and merged one at a time.
lightdash-agent-slack-messaging
6.2kHelps your agent write clear, friendly maintenance and activity reports for Lightdash administrators, based only on the evidence it has.
developing-in-lightdash
6.2kHelps your agent read, create and edit Lightdash dashboards and charts as JSON, including each chart type's settings.
filter-expressions
6.2kHelps your agent write correct filter expressions for Lightdash metric queries, including filters on custom metrics.
Similar skills
gitcrawl
394kLets your agent search a saved archive of GitHub issues and pull requests, group duplicates, and check their current status on GitHub.
slacrawl
394kLets your agent search and count messages in a local Slack archive, check how fresh that archive is, and refresh it when needed.
goplaces
394kHelps your agent search for places, get their details and reviews, and resolve place names using Google Places, with JSON output for scripts.