Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
mshailaja
Contributor III
Contributor III

Remove last letters

Hi

i have the table in which one filed values are like that

Server is the Fieldname and the values are

Server1-AP-DEV

Server2-AP-QA

Server3-AP-PRD

Server4-AP-DEV

Server5-AP-QA

Server2-AP-PRD

I need to be the fileds as like below

Server1-AP

Server2-AP

server3-AP

I applied the logic as like below for DEV

But i need for DEV,QA,PRD

Can any one please look into it

if(right(Server,4)='-DEV',Replace(Server,Right(Server,4),''),Server) as server1

13 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

To remove the last subfield regardless of the number of hyphens, use

=Replace(Field, '-' & SubField(Field, '-', -1), '')

(Replace Field with the correct fieldname)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

=Left(Field, Index(Field, '-', -1)-1)

Help users find answers! Don't forget to mark a solution that worked for you!
swuehl
MVP
MVP

Or maybe something like

MAP:

MAPPING LOAD * INLINE [

F1,F2

-CONT,

-DEV,

-PRD,

-UAT,

];

LOAD *, Trim(MapSubString('MAP',Server)) as ServerNew INLINE [

Server
HSU-SGD-ICPM-MANAGement

HSU-SGD-ICPM-MANAGement-CONT

HSU-SGD-ICPM-MANAGement-DEV

HSU-SGD-ICPM-MANAGement-PRD

HKU-SPD-ICPMPI-MANAGement

HKU-SPD-ICPMPI-MANAGement-DEV

HKU-SPD-ICPMPI-MANAGement-UAT

];

But it's really depending on the possible values. Above will only work if you need to remove the mapping table values from your server field field values (and they can't appear as valid part of your server name that you want to keep).

mshailaja
Contributor III
Contributor III
Author

Hi  ,

Thnks for all replies,

I have applied this logic and its working fie for me  now