Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
siva8
Contributor
Contributor

need help in qlik requirement

Hi Team 

 

can you please help me with the below scenario 

i have field name "mat" in my table which has data  like  is shown below 

Mat:

96-HF469A1-SRVC
UW-HA546A1-SRVC
SI-815100-B21-JK03
SI-865408-B21-JK03
TN-P00930-B21-JK03
UW-HA454A1-021-JK03

output should be like below

output:

HF469A1
HA546A1
815100-B21
865408-B21
P00930-B21
HA454A1-021

Thanks and regards

siva 

1 Solution

Accepted Solutions
zhadrakas
Specialist II
Specialist II

this should do what you need.

RAW:
Load if(SubStringCount(mat, '-') >=3,
		 subfield(mat, '-', 2) & '-' & subfield(mat, '-', 3),
    		subfield(mat, '-', 2))  as mat
;
LOAD * INLINE  [   
    mat
	96-HF469A1-SRVC
	UW-HA546A1-SRVC
	SI-815100-B21-JK03
	SI-865408-B21-JK03
	TN-P00930-B21-JK03
	UW-HA454A1-021-JK03
];

 

View solution in original post

2 Replies
zhadrakas
Specialist II
Specialist II

this should do what you need.

RAW:
Load if(SubStringCount(mat, '-') >=3,
		 subfield(mat, '-', 2) & '-' & subfield(mat, '-', 3),
    		subfield(mat, '-', 2))  as mat
;
LOAD * INLINE  [   
    mat
	96-HF469A1-SRVC
	UW-HA546A1-SRVC
	SI-815100-B21-JK03
	SI-865408-B21-JK03
	TN-P00930-B21-JK03
	UW-HA454A1-021-JK03
];

 

chakiw5
Contributor III
Contributor III

Please do call this writing to the module

function output(val)
dim p1,p2
p1=instr(val,"-")
p2=instrrev(val,"-")

output=Mid(val,p1+1,p2-(p1+1))

end function