Today, we began exploring calculated fields and all the functions that we may use in our daily lives. String functions were my main focus, which was brand new to me as I only have ever used to the number functions. Today, I will be making a quick guide on what some string functions do with examples of when you will use them along with their syntax.
STARTSWITH, ENDSWITH & CONTAINS:
You can use these functions to group depending on placement of characters within the string or even containing them. In this example, I am grouping sub categories of products sold depending on the first letter of the sub category.
![](https://www.thedataschool.co.uk/content/images/2023/04/Screenshot-2023-04-17-140901.png)
UPPER, LOWER & PROPER:
UPPER and LOWER is used to change the casing of characters in a string however, proper changes the first letter of each word to uppercase. In this example, I am using proper to capitalize the first letter of each word in the groups I have formed above.
![](https://www.thedataschool.co.uk/content/images/2023/04/Screenshot-2023-04-17-141328.png)
FIND:
Using the FIND function can be used in many ways. One way I utilized it was to find the space between the first name and last name from the customer name field.
![](https://www.thedataschool.co.uk/content/images/2023/04/Screenshot-2023-04-17-142019.png)
LEFT, RIGHT & MID:
You can use the above functions, depending on which direction you want to start counting the characters from, to separate strings in a field. For example, I want the function to return the first name from customer name. This is following on from using the FIND function.
![](https://www.thedataschool.co.uk/content/images/2023/04/Screenshot-2023-04-17-142237.png)
LEN:
This function returns the length of a string or the number of characters within a string. I found this function a bit difficult to use as I could not think of any situation where I would apply this function but the example below is a great way to use it. Using the LEN function to return the last name from customer name.
![](https://www.thedataschool.co.uk/content/images/2023/04/Screenshot-2023-04-17-143021.png)
REPLACE:
This function can be used to change the name of any records within a field, for this instance, I changed furniture to other within the category field.
![](https://www.thedataschool.co.uk/content/images/2023/04/Screenshot-2023-04-17-143249.png)
TRIM, LTRIM & RTRIM:
TRIM removes any spaces from the field from both sides whereas, LTRIM and RTRIM are only acting in one direction. In this example, I use TRIM to remove spaces from both sides of the email address field.
![](https://www.thedataschool.co.uk/content/images/2023/04/Screenshot-2023-04-17-143646.png)
SPLIT:
If you only want a certain amount of characters from a string, you can use the SPLIT function. Here, I use it to return only the first three characters from the product ID field.#
![](https://www.thedataschool.co.uk/content/images/2023/04/Screenshot-2023-04-17-144047.png)