Tableau LEFT and RIGHT Calculations
05 Apr

Tableau LEFT and RIGHT Calculations .

Tableau Tip Tuesdays | vizualintelligence | 0 Comments

LEFT

Returns a string value consisting of the number of characters specified in the second argument from the beginning (or left) of the string specified in the first argument. So if we look at the syntax below we see the LEFT formula, then the field we are grabbing from and then how many characters we want to grab. In the example below, we want to grab the month of the date which is always 2 characters long and the first 2 characters on the left.  Now the reason we have to do this is because this Order Date field is actually a string dimension which is the only type of data LEFT and RIGHT works on and at the end of this example we will convert this string into a date data type.

 

 

RIGHT

Right is the same thing as left but grabs the last characters in the string and starts from the right. Right returns a string value consisting of the number of characters specified in the second argument from the end (or right) of the string specified in the first argument. Here we are grabbing the year which is the last 4 characters in this string. Now you may be asking why would we do this? A perfect example is sometimes dates come over as string values and you will need to parse out the date parts and use the MAKEDATE() calculation to convert it to a Date data type. Below is also an example of how you can do that.

 

 

 

 

 

 

 

Now this is just 1 example of how you can use the LEFT() and RIGHT() calculation. These are very simple but come it handy when your data is not perfectly how you want it. It’s nice to have these in your back pocket whenever you need it, they can also do some powerful substring calculations partnered with a few other string calculations.

NO COMMENTS

DARE TO LEAVE A REPLY?