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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
zwyne
Creator
Creator

Extract specific words from a text field

Hello everyone, 

PFA

I am trying to extract words from a string with variable length,

StringExpected Result
BAGL - BSAA Business Bank - CABusiness Bank
BAGL - BSAA CIB - CACIB
BAGL - BSAA EDCON - CAEDCON
BAGL - BSAA PEP Stores - CAPEP Stores
BAGL - BSAA Retail - CARetail 
BAGL - BSAA WFS - CAWFS
BAGL - BSAA WIMI - CAWIMI
BAGL - BSAA WIMI ROA - CAWIMI ROA
BAGL - Botswana - CABotswana
BAGL - Ghana - CAGhana
BAGL - Kenya - CAKenya
BAGL - Mauritius - CAMozambique
1 Solution

Accepted Solutions
sunny_talwar

Try this

Table:
LOAD String,
	 Right(SubField(SubField(String, ' - CA', 1), ' - ', 2), Len(SubField(SubField(String, ' - CA', 1), ' - ', 2)) - Index(SubField(SubField(String, ' - CA', 1), ' - ', 2), ' ', 1)) as [Expected Result]
FROM
[..\..\Downloads\Sample Data.xlsx]
(ooxml, embedded labels, table is Document_LB04);

View solution in original post

2 Replies
sunny_talwar

Try this

Table:
LOAD String,
	 Right(SubField(SubField(String, ' - CA', 1), ' - ', 2), Len(SubField(SubField(String, ' - CA', 1), ' - ', 2)) - Index(SubField(SubField(String, ' - CA', 1), ' - ', 2), ' ', 1)) as [Expected Result]
FROM
[..\..\Downloads\Sample Data.xlsx]
(ooxml, embedded labels, table is Document_LB04);
zwyne
Creator
Creator
Author

Thank you Sunny, always a pleasure