LibreOffice Calc: Retrieve Substring from String in Formula


I introduce the way to retrieve substring from string in LibreOffice Calc formula. This way can be also applied for Microsoft Office Excel.

Environment

  • LibreOffice 5.1.4.2

Here, there are 3 methods to retrieve substring.

  • LEFT
  • RIGHT
  • MID

LEFT

Get characters from left side of the string.

Use it like LEFT("text", [the number of characters you want]). If you omit the number of characters to retrieve, the function returns left most one characters.

The number you entered is less than the original text, the function returns the original one.

RIGHT

Get characters from right side of the string.

Use it like LEFT("text", [the number of characters you want]). If you omit the number of characters to retrieve, the function returns right most one character.

The number you entered is less than the original text, the function returns the original one.

MID

MID returns the specified number of characters in a text string, starting from a specified position.

Use it like MID("text", [starting position], [the number of characters you want]). You can’t omit start position or the number of characters.

If the starting position is larger than the text length, the function returns blank text. If the number of characters you specified is larger than the number of characters you can retrieve, the function returns the text from the starting point to the end.

And More

MID can replace LEFT and RIGHT.

LEFT("text", x) is the same as MID("text", 1, x).

RIGHT("text", x) is the same as MID("text", LEN("text") - x + 1, x). LEN is the function that returns the number of characters.