MID
A number of characters from a text, from a position.
Group: Text. Compatible with DAX.
Syntax
MID ( <text>, <start_num>, <num_chars> )
| Parameter | Type | Description |
|---|---|---|
text | Text | The text to take characters from; a number becomes text first. |
start_num | Whole number | Where to begin: 1 is the text's first character. |
num_chars | Whole number | How many characters to take. |
Returns
Text. The characters from that position on, as many as asked for or as there are.
Remarks
- A start past the end gives empty text; more characters than are left gives the rest of the text.
- A start below 1, or a negative number of characters, is an error.
- A blank text gives BLANK.
- With
FINDorSEARCHfor the start, it takes the part of a text between two markers.
Examples
Characters from a position
EVALUATE
ROW (
"Nine from the 1st", MID ( "Trondheim plant", 1, 9 ),
"Past the end", MID ( "abc", 5, 2 ),
"More than are left", MID ( "abc", 2, 99 )
)
| Nine from the 1st | Past the end | More than are left |
|---|---|---|
| Trondheim | (empty text) | bc |
The middle of a code
EVALUATE
ROW ( "Postcode", MID ( "NO-0150-OSL", 4, 4 ) )
| Postcode |
|---|
| 0150 |