0
votes

My data in a single column looks like this

Environment: PROD_A
JobName: MY JOB NAME 1
MemName: Some_Script_names

My aim is to create a calculated field where it fetches JobName. In above sample. The output should be MY_JOB_NAME_1

Here's my code in Tableau -

MID([Description],FIND([Description],"JobName: ")+9,
FIND([Description],"MemName: ")-FIND([Description],"JobName: ")-9)

The above logic is same as excel function below. It basically finds first word and last word and then picks the one in between.

=MID(A1,SEARCH("JobName: ",A1)+9,SEARCH("MemName",A1)-SEARCH("JobName: ",A1)-9)

Issue - Tableau is showing blank data. Not sure where my logic is wrong. Any help is appreciated.

3
Is each line in your sample a separate row or are they all in one row? - Bernardo
@Bernardo single row - Pirate X

3 Answers

1
votes

You may be able to use REGEX funtions (depending on your data source). Try this: REGEXP_EXTRACT([Data],'JobName: (.*)')

1
votes

I see that you commented that the text is in one cell and not one column as you wrote in question.

This finds the JobName and uses that position plus the lenght of it as the startposition, then finds MemName as the endposition (and calculates the number of characters between them)

=MID(A1,FIND("JobName: ",A1)+LEN("JobName: "),FIND("MemName",A1,FIND("JobName: ",A1)+LEN("JobName: ")+1)-(FIND("JobName: ",A1)+Len("JobName: ")))

enter image description here

0
votes

The following tableau calc works, this assumes that there is no space after MY_JOB_NAME_1 and "MemName:"

MID([Text], 
FIND([Text],'JobName: ')+10, 
FIND( 
MID([Text], 
FIND([Text],'JobName: ')+10)," ")-9)