Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikview979
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
sunny_talwar

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
YoussefBelloum
Champion
Champion

Hi,

try this:

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

sunny_talwar

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

];

qlikview979
Specialist
Specialist
Author

Hi,

It will not give correct output.

here i want to replace only  last underscore not all.

qlikview979
Specialist
Specialist
Author

Hi Bro,

here after last _ first is missing its giving like

LYTHSM_TD


but i need LYTHSM_STD

qlikview979
Specialist
Specialist
Author

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;

Digvijay_Singh

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.

sunny_talwar

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

];

qlikview979
Specialist
Specialist
Author

Yes bro, its perfectly working

you  are master of Qlik

Regards

Mahesh