DAX function
MID — DAX function reference
Characters from a position.
Syntax
dax
MID(<text>, <start_num>, <num_chars>)
Examples
dax
MID([Code], 4, 2)
→ A substring
dax
MID(Product[SKU], 5, 3)
→ A 3-character segment starting at position 5, e.g. an embedded plant code
dax
MID(Customer[Phone], LEN(Customer[Phone]) - 3, 4)
→ The last 4 digits, computed dynamically without hardcoding a start position
Common mistakes & gotchas
- start_num is 1-based (the first character is position 1, not 0), which trips up anyone coming from a 0-indexed language.
- If start_num is beyond the end of the string, MID returns an empty string rather than an error — useful when parsing variable-length codes without extra guard logic.
Related DAX functions
From Text