Qlik Community

Ask a Question

New to QlikView

If you’re new to QlikView, start with this Discussion Board and get up-to-speed quickly.

Announcements
Welcome to our newly redesigned Qlik Community! Read our blog to learn about all the new updates: READ BLOG and REPORTED ISSUES
cancel
Showing results for 
Search instead for 
Did you mean: 
Specialist
Specialist

Replace

Hi Experts

I have data like below format, here my requirement is i want replace the '_' (last underscore) with '-' (hi-fen).

stalwar1omarbensalemyoussefbelloum

My data  like

Input

LUNG_GI_ATEZO

LUNG_GI_GI

LUNG_GI_LUNGA

LYT_STD

LYTHSM_STD

OCREView

O/P:-

LUNG_GI-ATEZO

LUNG_GI-GI

LUNG_GI-LUNGA

LYT-STD

LYTHSM-STD

OCREView

Regards

Mahesh

1 Solution

Accepted Solutions

Yes, you are right... this should work

Table:

LOAD *,

If(Index(Input, '_', -1), Left(Input, Index(Input, '_', -1) - 1) & '-' & Right(Input, Len(Input) - Index(Input, '_', -1)), Input) as Output;

LOAD * INLINE [

    Input

    LUNG_GI_ATEZO

    LUNG_GI_GI

    LUNG_GI_LUNGA

    LYT_STD

    LYTHSM_STD

    OCREView

];

View solution in original post

8 Replies
Champion
Champion

Hi,

try this:

Replace(Input,'_','-')

This

Table:

LOAD *,

If(Index(Input, '_', -1), Left(Input, Index(Input, '_', -1) - 1) & '-' & Right(Input, Len(Input) - Index(Input, '_', -1) - 1), Input) as Output;

LOAD * INLINE [

    Input

    LUNG_GI_ATEZO

    LUNG_GI_GI

    LUNG_GI_LUNGA

    LYT_STD

    LYTHSM_STD

    OCREView

];

Specialist
Specialist

Hi,

It will not give correct output.

here i want to replace only  last underscore not all.

Specialist
Specialist

Hi Bro,

here after last _ first is missing its giving like

LYTHSM_TD


but i need LYTHSM_STD

Specialist
Specialist

may be it will work right

If(Index(Input, '_', -1), Left(Input, Index(Input, '_', -1) - 1) & '-' & Right(Input, Len(Input) - Index(Input, '_', -1) ), Input) as Output;

Master III
Master III

Try this as well -

=Left('LUNG_GI_ATEZO',index('LUNG_GI_ATEZO','_',-1)-1)&'-'&Subfield('LUNG_GI_ATEZO','_',-1)

Replace string with the field name.

Yes, you are right... this should work

Table:

LOAD *,

If(Index(Input, '_', -1), Left(Input, Index(Input, '_', -1) - 1) & '-' & Right(Input, Len(Input) - Index(Input, '_', -1)), Input) as Output;

LOAD * INLINE [

    Input

    LUNG_GI_ATEZO

    LUNG_GI_GI

    LUNG_GI_LUNGA

    LYT_STD

    LYTHSM_STD

    OCREView

];

View solution in original post

Specialist
Specialist

Yes bro, its perfectly working

you  are master of Qlik

Regards

Mahesh