Solved

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:

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)

icon

Best answer by Jimmy_Westman 10 June 2022, 14:56

View original

2 replies

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!

Reply