Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
FranciscoQ
Partner - Creator
Partner - Creator

String Functions in a variable, Subfield, DocumentTitle

Hi !

 

I need to create a variable with a part of the name of the application.  But, the thing is that this function can be replicated in multiple apps, with different names.

All the apps have something in common, they are all named XXX_XXX_XXX_XXXX_XXXXX

The X's are different letters (they mean enviorments QA, STAGE, PRD, DATA, STAGE, datasource, tablename, etc).

The thing is all of strings are separated by "_". And I need always de first 3 strings, as well as the "_".

 

So if an APP is named:

QA_DATA_SQL_ACCOUNTS. 

I need the value QA_DATA_SQL in a variable.

But I want to copy and paste the variable definition to all my apps, so if I use the variable in another script, where the app is named

PRD_STG_ORACLE_CUSTOMERS, the output should be "PRD_STG_ORACLE".

 

So I need the first, the second and the third word, and also the delimiter (_).

 

I though in using FILENAME function and also subfield. But IDK how to use multiple string functions in a variable, like:

LET S_ENVIORMENT= SUBFIELD(DocumentTitle(),'_',1)&'_'&SUBFIELD(DocumentTitle(),'_',2)&'_'&SUBFIELD(DocumentTItle(),'_',3);

 

I would appreciate some help.

 

Thanks!

Labels (1)
2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

What you posted:

LET S_ENVIORMENT= SUBFIELD(DocumentTitle(),'_',1)&'_'&SUBFIELD(DocumentTitle(),'_',2)&'_'&SUBFIELD(DocumentTItle(),'_',3);

looks correct. Does it not work?

-Rob

FranciscoQ
Partner - Creator
Partner - Creator
Author

I was using Filename in the script instead of document title (like I posted here). So that why it wasn't working.

It's definitely correct.