Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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 - Creator
Partner - Creator

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

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

];

Anonymous
Not applicable
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

Anonymous
Not applicable
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;

Anonymous
Not applicable
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;