The DAX extension provides comprehensive support for Power BI's Data Analysis Expressions (DAX) language, including syntax highlighting, code formatting, and real-time error detection.
DAX 扩展为 Power BI 的数据分析表达式 (DAX) 语言提供全面支持,包括语法高亮、代码格式化和实时错误检测。
Features

1. Syntax Highlighting
- Full syntax highlighting for DAX language
- Supports
.dax file extension
- Works in Markdown code blocks (
dax, DAX, ```Dax)
- Highlights functions, keywords, strings, comments, and operators
- One-click code formatting (Cmd+Shift+F / Ctrl+Shift+F)
- Command: "Format Document"
- Automatic indentation for nested functions
- Adds spaces around operators
- Preserves comments and blank lines
3. Real-time Diagnostics
- Detects Chinese characters (parentheses, commas, full-width spaces)
- Checks for unmatched parentheses and brackets
- Identifies unclosed strings
- Shows error messages with red underlines
功能特性
1. 语法高亮
- 完整的 DAX 语言语法高亮
- 支持
.dax 文件扩展名
- 支持 Markdown 代码块中的高亮(
dax, DAX, ```Dax)
- 高亮显示函数、关键字、字符串、注释和运算符
2. 代码格式化
- 一键格式化代码(Cmd+Shift+F / Ctrl+Shift+F)
- 右键选择命令 "Format Document"
- 自动缩进嵌套函数
- 在运算符周围添加空格
- 保留注释和空行
3. 实时诊断
- 检测中文字符(括号、逗号、全角空格)
- 检查括号和方括号是否匹配
- 识别未闭合的字符串
- 用红色下划线显示错误信息
Usage Examples
CALCULATE(SUM([Sales]),FILTER('Table1','Table1'[Date]=MAX('Table1'[Date])))
CALCULATE(
SUM([Sales]),
FILTER(
'Table1',
'Table1'[Date] = MAX('Table1'[Date])
)
)
Error Detection:
The extension will highlight errors like:
- Chinese parentheses:
CALCULATE(SUM([Sales])) ❌
- Chinese comma:
CALCULATE(SUM([Sales]),FILTER(...)) ❌
- Unmatched parentheses:
CALCULATE(SUM([Sales]) ❌
Installation
- Install from VS Code Marketplace
- Open any
.dax file
- The extension will activate automatically
Commands
- Format DAX Document: Format the current DAX file
- Keyboard:
Cmd+Shift+F (Mac) / Ctrl+Shift+F (Windows)
- Command Palette:
Format DAX Document
Requirements
Release Notes
Version 0.1.1 (2026-02-26)
- Fixed formatter bugs for improved code formatting quality
Version 0.1.0 (2026-02-23)
- Updated to 2026-02 DAX function list (466 functions total, +21 new functions)
- Added 8 week-related time intelligence functions
- CLOSINGBALANCEWEEK, DATESWTD, ENDOFWEEK, STARTOFWEEK
- NEXTWEEK, PREVIOUSWEEK, OPENINGBALANCEWEEK, TOTALWTD
- Added 11 type checking functions
- ISBOOLEAN, ISCURRENCY, ISDATETIME, ISDECIMAL, ISDOUBLE
- ISINT64, ISINTEGER, ISNUMERIC, ISSTRING
- EXTERNALMEASURE, TABLEOF
- Added 2 visual calculation lookup functions
- Added syntax highlighting support for Markdown editor and Markdown Preview
- Added code formatting with automatic indentation and operator spacing
- Added real-time diagnostics for Chinese characters and syntax errors
Version 0.0.13 (2025-03-18)
- Updated to 2025 DAX function list (445 functions total)
- Added 12 visual calculation functions for Power BI visual-level calculations
- COLLAPSE, COLLAPSEALL, EXPAND, EXPANDALL
- FIRST, ISATLEVEL, LAST, MOVINGAVERAGE
- NEXT, PREVIOUS, RANGE, RUNNINGSUM
- Enhanced code snippets with function categories (DATETIME, FILTER, WINDOW, etc.)
- Added support for financial functions (ACCRINT, DB, XIRR, etc.)
- Added support for engineering functions (BITAND, BITOR, BITXOR, etc.)
- Added support for system functions (INFO.* series)
Version 0.0.12 (2024-03-22)
- Added visual calculation functions:
- COLLAPSE, COLLAPSEALL, EXPAND, EXPANDALL
- FIRST, ISATLEVEL, LAST, LOOKUP
- MOVINGAVERAGE, NEXT, PREVIOUS
- RANGE, RUNNINGSUM
References
Enjoy coding with DAX! 🚀
| |