Excellency

View Original

The MID function

The MID function is a text function which returns a substring of characters from a larger string. This function will return a substring regardless of the formatting of the values in the original string. Properly formatted date fields will not return substrings of the long form date, only a substring of the number representing the date shown.

This is the format of the MID function:

=MID(STRING, STARTING CHARACTER, NUMBER OF CHARACTERS)

Here is an example of the MID function:

=MID(“Dark chocolate is better than white chocolate”, 6, 9) = “chocolate” 

MID function returning the substring of text which is 9 characters long, starting at the 6th character or the selected text

This function is valuable when you are isolating sub-strings from a piece of text which has been imported from an external source. Often times these sources may concatenate information using a standard delimiter which could even be in the form of keywords which transition between segments of the description.

An example of a functional implementation of this would be having a valuable descriptor which resides within a larger string of text, for example if you are tracking the stock market and you want to extract the ticker symbol from the rest of the description.

ex: All descriptions start with the market the stock is on, followed by a colon, and then the ticker itself

=MID(“TSE:TD ……”, SEARCH(“:”, “TSE:TD ……”)+1, SEARCH(“ ”, “TSE:TD ……”)- SEARCH(“:”, “TSE:TD ……”)-1)

* Note this example uses the SEARCH function to dynamically extract values based on known consistent parameters *