Qlik Community

Ask a Question

New to Qlik Sense

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

Announcements
Our May 2021 end-to-end product release from Data Integration to Data Analytics is out! READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
sandrapinto
Contributor III
Contributor III

Function to Reverse String / text

Hi

I am getting revered string from my system. For Example Item ABCD is loaded as DCBA.

Is there a function I can use to reverse the string, in the script itself?

Here is the script:

LIB CONNECT TO 'Sandra-Lavi (lavi_sandra)';

Parts:

LOAD

    Text(PARTNAME) as Parts.PARTNAME ;

SQL SELECT

PARTNAME,

....

FROM lavi.dbo.PART;

Thanks !!

Sandra

1 Solution

Accepted Solutions
YoussefBelloum
Champion
Champion

try this:

LIB CONNECT TO 'Sandra-Lavi (lavi_sandra)';

Parts:

LOAD Parts.PARTNAME, concat(Letter,'',-row) as Reversed Group by Parts.PARTNAME;

LOAD

Text(PARTNAME) as Parts.PARTNAME,

interno() as row,

mid(Text(PARTNAME),Iterno(),1) as Letter

While IterNo() <= len(MyText);

SQL SELECT

PARTNAME,

....

FROM lavi.dbo.PART;

View solution in original post

13 Replies
jmmolero
Partner
Partner

I think that better option is Reverse() function of your ODBC. Oracle, MS SQL and Mysql have this funcition.

In Qlik you will need a lot of code.

YoussefBelloum
Champion
Champion

Hi,

read this:

Reverse string

OmarBenSalem
Partner
Partner

Try :

Load

  MyText,

  Concat(Letter,'',-row) as Reversed

Group By MyText;

Load

  MyText,

  IterNo() as row,

  Mid(MyText,IterNo(),1) As Letter

Inline

[

MyText

  DCBA

] While IterNo() <= Len(MyText);

Result:

Capture.PNG

sunny_talwar

Something like this might work

Table:

LOAD F1,

Concat(F1_Temp, '', -SNo) as F1_New

Group By F1;

LOAD AutoNumber(IterNo(), F1) as SNo,

F1,

Mid(F1, IterNo(), 1) as F1_Temp

While IterNo() <= Len;

LOAD F1,

Len(F1) as Len;

LOAD * INLINE [

    F1

    ABCD

    KLMASL

];

sandrapinto
Contributor III
Contributor III
Author

thanks,

I tried applying this to my script but didn't succeed

could you help me apply this to my script?

YoussefBelloum
Champion
Champion

of course, attach your script

sandrapinto
Contributor III
Contributor III
Author

Here is the script:

LIB CONNECT TO 'Sandra-Lavi (lavi_sandra)';

Parts:

LOAD

    Text(PARTNAME) as Parts.PARTNAME ;

SQL SELECT

PARTNAME,

....

FROM lavi.dbo.PART;

YoussefBelloum
Champion
Champion

try this:

LIB CONNECT TO 'Sandra-Lavi (lavi_sandra)';

Parts:

LOAD Parts.PARTNAME, concat(Letter,'',-row) as Reversed Group by Parts.PARTNAME;

LOAD

Text(PARTNAME) as Parts.PARTNAME,

interno() as row,

mid(Text(PARTNAME),Iterno(),1) as Letter

While IterNo() <= len(MyText);

SQL SELECT

PARTNAME,

....

FROM lavi.dbo.PART;

View solution in original post

sandrapinto
Contributor III
Contributor III
Author

thanks!

I assume you meant to put "PARTNAME" instead of MyText, right?

This is my script now.

and it still bring the reversed text..

Is there something wring with this ?

LIB CONNECT TO 'Sandra-Lavi (lavi_sandra)';


Parts:

LOAD Parts.PARTNAME, concat(Letter,'',-row) as Reversed Group by Parts.PARTNAME;

LOAD

Text(PARTNAME) as Parts.PARTNAME,

iterno() as row,

mid(Text(PARTNAME),Iterno(),1) as Letter

While IterNo() <= len(Text(PARTNAME));


SQL SELECT

PARTNAME

FROM lavi.dbo.PART;


load Text(PARTNAME), iterno() as row, mid(Text(PARTNAME),IterNo(),1) As Letter;


exit Script;