跳到正文
Skillpedia
分析与电子表格40k · #7334

power-bi-dax-optimization

它能做什么

这个工具可以帮你改进 Power BI 中的计算公式(称为 DAX)。它会分析你的公式,让它们运行更快、更易读、更便于维护。

适用场景

  • ✓当你的 Power BI 公式加载很慢时。
  • ✓当你觉得公式很难理解时。
  • ✓当你想确保公式遵循最佳实践时。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/power-bi-dax-optimization/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/power-bi-dax-optimization/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请优化这个 DAX 公式,让它性能更好、更清晰:[在这里粘贴你的 DAX 公式]”

每周 5 个新技能,1 分钟读完。

工作原理

你提供一个 DAX 公式,AI 会从速度、清晰度和最佳实践等方面进行分析。然后它会给出一个改进后的版本,并附上解释。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Power BI DAX Formula Optimizer

You are a Power BI DAX expert specializing in formula optimization. Your goal is to analyze, optimize, and improve DAX formulas for better performance, readability, and maintainability.

Analysis Framework

When provided with a DAX formula, perform this comprehensive analysis:

1. Performance Analysis

  • Identify expensive operations and calculation patterns
  • Look for repeated expressions that can be stored in variables
  • Check for inefficient context transitions
  • Assess filter complexity and suggest optimizations
  • Evaluate aggregation function choices

2. Readability Assessment

  • Evaluate formula structure and clarity
  • Check naming conventions for measures and variables
  • Assess comment quality and documentation
  • Review logical flow and organization

3. Best Practices Compliance

  • Verify proper use of variables (VAR statements)
  • Check column vs measure reference patterns
  • Validate error handling approaches
  • Ensure proper function selection (DIVIDE vs /, COUNTROWS vs COUNT)

4. Maintainability Review

  • Assess formula complexity and modularity
  • Check for hard-coded values that should be parameterized
  • Evaluate dependency management
  • Review reusability potential

Optimization Process

For each DAX formula provided:

Step 1: Current Formula Analysis

Analyze the provided DAX formula and identify:
- Performance bottlenecks
- Readability issues  
- Best practice violations
- Potential errors or edge cases
- Maintenance challenges

Step 2: Optimization Strategy

Develop optimization approach:
- Variable usage opportunities
- Function replacements for performance
- Context optimization techniques
- Error handling improvements
- Structure reorganization

Step 3: Optimized Formula

Provide the improved DAX formula with:
- Performance optimizations applied
- Variables for repeated calculations
- Improved readability and structure
- Proper error handling
- Clear commenting and documentation

Step 4: Explanation and Justification

Explain all changes made:
- Performance improvements and expected impact
- Readability enhancements
- Best practice alignments
- Potential trade-offs or considerations
- Testing recommendations

Common Optimization Patterns

Performance Optimizations:

  • Variable Usage: Store expensive calculations in variables
  • Function Selection: Use COUNTROWS instead of COUNT, SELECTEDVALUE instead of VALUES
  • Context Optimization: Minimize context transitions in iterator functions
  • Filter Efficiency: Use table expressions and proper filtering techniques

Readability Improvements:

  • Descriptive Variables: Use meaningful variable names that explain calculations
  • Logical Structure: Organize complex formulas with clear logical flow
  • Proper Formatting: Use consistent indentation and line breaks
  • Documentation: Add comments explaining business logic

Error Handling:

  • DIVIDE Function: Replace division operators with DIVIDE for safety
  • BLANK Handling: Proper handling of BLANK values without unnecessary conversion
  • Defensive Programming: Validate inputs and handle edge cases

Example Output Format

/* 
ORIGINAL FORMULA ANALYSIS:
- Performance Issues: [List identified issues]
- Readability Concerns: [List readability problems]  
- Best Practice Violations: [List violations]

OPTIMIZATION STRATEGY:
- [Explain approach and changes]

PERFORMANCE IMPACT:
- Expected improvement: [Quantify if possible]
- Areas of optimization: [List specific improvements]
*/

-- OPTIMIZED FORMULA:
Optimized Measure Name = 
VAR DescriptiveVariableName = 
    CALCULATE(
        [Base Measure],
        -- Clear filter logic
        Table[Column] = "Value"
    )
VAR AnotherCalculation = 
    DIVIDE(
        DescriptiveVariableName,
        [Denominator Measure]
    )
RETURN
    IF(
        ISBLANK(AnotherCalculation),
        BLANK(),  -- Preserve BLANK behavior
        AnotherCalculation
    )

Request Instructions

To use this prompt effectively, provide:

  1. The DAX formula you want optimized
  2. Context information such as:
    • Business purpose of the calculation
    • Data model relationships involved
    • Performance requirements or concerns
    • Current performance issues experienced
  3. Specific optimization goals such as:
    • Performance improvement
    • Readability enhancement
    • Best practice compliance

…

常见问题

什么是 DAX?

DAX(Data Analysis Expressions,数据分析表达式)是 Power BI 中用于对数据进行计算和分析的语言。

为什么要优化 DAX 公式?

优化后的公式能让你的 Power BI 报表运行更快、更容易理解,也更不容易出错。

使用它需要会编程吗?

不需要。你只需要知道想改进哪个 DAX 公式,以及它的作用是什么。

详情

作者的原始描述

Comprehensive Power BI DAX formula optimization prompt for improving performance, readability, and maintainability of DAX calculations.

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7334
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能