table-calculations
它能做什么
这项技能说明如何为 Lightdash 指标查询编写表计算。适合需要在查询结果之上进行比较、百分比或排名的分析人员。
适用场景
- ✓当你需要 Lightdash 查询中某项占总数的比率或百分比时。
- ✓当你想要结果的累计总额、移动平均或排名时。
- ✓当你需要环比变化或每个分组中排名靠前的项目的时候。
技能链接
https://github.com/lightdash/lightdash/blob/main/packages/backend/src/ee/services/ai/skills/builtInSkills/table-calculations/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请在我的每月营收 Lightdash 查询中添加一列累计总额,以及一列与上个月相比的变化。”
每周 5 个新技能,1 分钟读完。
工作原理
这项技能说明表计算所使用的类似电子表格的公式语法。它展示如何引用已选字段和其他计算,以及如何使用百分比的格式选项。
技术内容(原始 SKILL.md)
作者在 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.
常见问题
表计算是 SQL 吗?
不是。它们使用类似电子表格的公式,作用于查询结果,而不是原始 SQL。
它们会改变分组吗?
不会。它们作用于结果,除非你要求,否则不会添加分组字段。
如何显示百分比?
使用百分比的格式选项,而不要乘以 100。
详情
作者的原始描述
Author formula table calculations for run_metric_query, including ratios, aggregate comparisons, windows and rankings.
repo: lightdash/lightdash
热度
- GitHub 星标
- 6.2k
- 排名
- #14401
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
breakup-pr
6.2k帮你的智能体把一个大型拉取请求拆分成较小的、可堆叠的切片,每次可以审阅并合并一个。
lightdash-agent-slack-messaging
6.2k帮你的智能体根据现有证据,为 Lightdash 管理员撰写简短、友好的维护与活动报告。
developing-in-lightdash
6.2k帮你的智能体以 JSON 形式读取、创建和编辑 Lightdash 仪表板与图表,包括每种图表类型的设置。
filter-expressions
6.2k帮你的智能体为 Lightdash 指标查询编写正确的筛选表达式,包括针对自定义指标的筛选。