Extracting substring from a long group name

Hi! I am very new to looker and was hoping someone would be able to help me. So I currently am working on a look that has a dimension username and a measure that returns the group that the username is from. I am trying to find a way to create a separate column that extracts just the beginning part of the group name, and not the numbers and letters that follow it. I have been trying to use the table calculation (since I do not have access to LookML) but it keeps returning 0. 

For reference:

f3249fa4-4582-4ab6-9b01-b16c134dc7a0.png

How can I get it to just return “Delta Group” from the “delta group-564f6dffa-dc….”
*note: all group names are followed by a dash before the letters and numbers ([name]-123abd-456def)

Solved Solved
0 2 1,587
1 ACCEPTED SOLUTION

Hello!

This should work in a table calculation:

substring(${xxxxx.yyyyy},1,position(${xxxxxx.yyyyy},"-")-1)

Where xxxxx.yyyyy is the measure containing the group name.

This calculation takes a substring from the column xxxxx.yyyyy, starting at position 1 (first character) and ending at the position of the “-” -1.

I have only done this with dimensions myself, but I’m guessing it would work with a measure as well. If it complains that the measure is not a string, try adding the to_string-function

View solution in original post

2 REPLIES 2

Hello!

This should work in a table calculation:

substring(${xxxxx.yyyyy},1,position(${xxxxxx.yyyyy},"-")-1)

Where xxxxx.yyyyy is the measure containing the group name.

This calculation takes a substring from the column xxxxx.yyyyy, starting at position 1 (first character) and ending at the position of the “-” -1.

I have only done this with dimensions myself, but I’m guessing it would work with a measure as well. If it complains that the measure is not a string, try adding the to_string-function

Hi Jimmy! Thank you so much for your help. This worked perfectly. I appreciate it!

Top Labels in this Space
Top Solution Authors