Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

puttemans
Valued Contributor

Invert content of a variable

Dear all,

I'm facing this issue where I really need a solution for.

I have a file containing an identifier (MORO-ID) and a route. This route is composed of a varying number of stationcodes, each time separated by a semicolon. For some of the MORO-ID's, I now need to invert the route. So given a route a;b;c;d;e;f;g this would need to become g;f;e;d;c;b;a

Could anyone give me a hint on how to tackle this?

(file attached)


1 Solution

Accepted Solutions
amarbogam
Contributor

Re: Invert content of a variable

See the attached file,

Data:

Load

*,

100000000- rowno() as Seqno

Where len(REV_ROUTE_TEMP)>0

;

LOAD [MORO_ID           ] as MORO_ID,

     ROUTE,

     subfield(trim(ROUTE),';') as REV_ROUTE_TEMP

    

FROM

[MOBIB_ROUTE_2015.qvd]

(qvd);

Data2:

NoConcatenate

Load

MORO_ID,

';'&Concat(REV_ROUTE_TEMP,';',Seqno)&';' as REV_ROUTE

Resident Data

group by MORO_ID

;

drop table Data;

3 Replies
jpenuliar
Valued Contributor III

Re: Invert content of a variable

see below:

Reverse string

amarbogam
Contributor

Re: Invert content of a variable

See the attached file,

Data:

Load

*,

100000000- rowno() as Seqno

Where len(REV_ROUTE_TEMP)>0

;

LOAD [MORO_ID           ] as MORO_ID,

     ROUTE,

     subfield(trim(ROUTE),';') as REV_ROUTE_TEMP

    

FROM

[MOBIB_ROUTE_2015.qvd]

(qvd);

Data2:

NoConcatenate

Load

MORO_ID,

';'&Concat(REV_ROUTE_TEMP,';',Seqno)&';' as REV_ROUTE

Resident Data

group by MORO_ID

;

drop table Data;

puttemans
Valued Contributor

Re: Invert content of a variable

Hello Amarbogam,

Thank you for your solution. To me, it is really impressing. In just 20 seconds, all lines are inverted !

Thanks a lot !!

Community Browser