The syntax for the LEFT function is as follows:
Where `text` is the string you want to extract from, and `num_chars` is the number of characters you want to extract.
Example 1: Extracting the First Name from a Full Name
Let's say you have a column in your data set that contains the full names of your customers, and you want to extract their first names. You can use the LEFT function to do this. Here is an example of how to do it:
=LEFT([Full Name], FIND(” “, [Full Name])-1)
In this example, we are using the FIND function to locate the first space in the full name and subtracting one to get the number of characters to extract. This will give us the first name of each customer.
Example 2: Extracting the First Two Characters of a Code
Let's say you have a column in your data set that contains codes for different products, and you want to extract the first two characters of each code. You can use the LEFT function to do this. Here is an example of how to do it:
=LEFT([Product Code], 2)
In this example, we are simply extracting the first two characters of each product code.
The LEFT function in Power BI is a powerful tool that can be used in many different scenarios. Whether you need to extract a specific subset of data or simply want to clean up your data set, the LEFT function can help. By understanding the syntax and examples provided in this article, you should be able to use the LEFT function in your own Power BI projects.
Power BI DAX Training Courses by G Com Solutions (0800 998 9248)
Power BI DAX Intensive Training Course£1,050.00 – £26,550.00
Power BI DAX Introduction£395.00 – £9,750.00
Power BI DAX Intermediate£395.00 – £9,750.00
Power BI DAX Advanced£395.00 – £9,750.00