Power Query Left Function using Text.Start
The power query left function can be replicated using Text.Start function. In most languages, we use the left function to extract the desired number of characters from the left side of the given string.
The syntax of the Text.Start function in the Power query is straightforward.
Text.Start(Given string, number of characters that needs to extract=
It takes two parameters.
- The first parameter is the given string.
- The second parameter is the number of characters we want to extract from the left side.
Power Query left function example.
Let’s see, we have a table that contains a list of months, and we want to extract the first three characters.
You need to follow the process step by step.
- Go to the Power query editor.
- Select add column
- Select custom column
- Write the name of the column. You can write any suitable name.
- Write the following formula.
Text.Start([Months],3)
The above procedure will create a new column, “Short Month,” containing the first three months’ characters, as you can see below.
If text.start power query
If condition with text.start power query function is very handy in a lot of scenarios.
Let’s try to write a formula to obtain all those months that begin with the letter “J”; otherwise, return null.
if Text.Start([Months],1) = "J" then [Months] else null
You will see the below results.
In this article, you have seen how to implement the power query left function with the help of Text.start function.
To learn more, please visit Learn DAX