Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
paulyeo11
Master
Master

Case 920 How to use Subfield to take out first 3 letter ?

Hi All

I have below raw data :-

// Step 1 Create Raw Data

Input_Sales:

LOAD * INLINE [
Customer/Vendor, Customer Name,Row Total (SGD)
CET00837-SGD, SUPER COMPONENTS (S) PTE LTD,7
CET00837-SGD, SUPER COMPONENTS (S) PTE LTD,6
VIT01610-USD, GRAND VENTURE TECHNOLOGY LIMITED
VIT01610-USD, GRAND VENTURE TECHNOLOGY LIMITED
LOA01999-USD, CONVERGENT SYSTEMS (S) PTE LTD,3
];

/*

Step 2 i need create new field = CUST_TYPE , fIELD NAME = Customer/Vendor :-

CET = CUSTOMER
VIT = SUPPLIER
LOA = INTER COY

May i know how to do ?

Paul Yeo

 

1 Solution

Accepted Solutions
Taoufiq_Zarra

@paulyeo11 

One solution:

map:
mapping LOAD * 
Inline [
CUSTCode, CUSTAttribute
1 ,CUSTOMER
2 ,SUPPLIER
3 ,INTER COY
] ;

Input_Sales:

LOAD *,ApplyMap('map', wildmatch( [Customer/Vendor], 'CET*','VIT*','LOA*')) as CUST_TYPE  INLINE [
Customer/Vendor, Customer Name,Row Total (SGD)
CET00837-SGD, SUPER COMPONENTS (S) PTE LTD,7
CET00837-SGD, SUPER COMPONENTS (S) PTE LTD,6
VIT01610-USD, GRAND VENTURE TECHNOLOGY LIMITED
VIT01610-USD, GRAND VENTURE TECHNOLOGY LIMITED
LOA01999-USD, CONVERGENT SYSTEMS (S) PTE LTD,3
];

 

output:

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

2 Replies
Taoufiq_Zarra

@paulyeo11 

One solution:

map:
mapping LOAD * 
Inline [
CUSTCode, CUSTAttribute
1 ,CUSTOMER
2 ,SUPPLIER
3 ,INTER COY
] ;

Input_Sales:

LOAD *,ApplyMap('map', wildmatch( [Customer/Vendor], 'CET*','VIT*','LOA*')) as CUST_TYPE  INLINE [
Customer/Vendor, Customer Name,Row Total (SGD)
CET00837-SGD, SUPER COMPONENTS (S) PTE LTD,7
CET00837-SGD, SUPER COMPONENTS (S) PTE LTD,6
VIT01610-USD, GRAND VENTURE TECHNOLOGY LIMITED
VIT01610-USD, GRAND VENTURE TECHNOLOGY LIMITED
LOA01999-USD, CONVERGENT SYSTEMS (S) PTE LTD,3
];

 

output:

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
paulyeo11
Master
Master
Author

Hi Sir

Thank you very much your script is very short.

map:
mapping LOAD *
Inline [
CUSTCode, CUSTAttribute
1 ,CUSTOMER
2 ,SUPPLIER
3 ,INTER COY
] ;

For Each i in 'SD','PM'

[Raw data]:
LOAD
'$(i)' as SOURCCE,
[Customer/Vendor],
ApplyMap('map', wildmatch( [Customer/Vendor], 'CET*','VIT*','LIR*')) as CUST_TYPE,
[Customer Name],
Email,
[E-Mail]
FROM
DB_$(i).csv
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);
next i;