Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
shayraber
Creator
Creator

changing the direction of a text

Hi,

I'm trying to change the direction at one of my dimensions which is a string.

The text is being presented from right to left and I'd like to change it to be from left to right, either at the script or as a text formating.

for example,

I'd like that the string appearing like this: rotoM ovreS will be shown like this: Servo Motor

Is it possible? please assist

Thanks and Best Regards,

Shai

1 Solution

Accepted Solutions
5 Replies
fdelacal
Specialist
Specialist

flipside
Partner - Specialist II
Partner - Specialist II

If you are doing this in load script, easiest way seems to be a JScript module...

function reverse(s){

    return s.split("").reverse().join("");

}

then just call it as follows ...

RevText:

Load Fld1, reverse(Fld1) as Fld1Rev resident data;

There are VBScript ways of doing this too, and you can mix VBscript with Jscript using MSScriptControl ...

function vbReverse(x)

set O = CreateObject("MSScriptControl.ScriptControl")

O.Language= "JScript"

O.AddCode "function reverse(s) {return s.split('').reverse().join('');}"

vbReverse = O.Run ("reverse",x)

end function

http://community.qlik.com/message/276330#276330 has more info on this.

flipside

flipside
Partner - Specialist II
Partner - Specialist II

Here's an option without using macros at all (will require strings to be unique though) ..

TmpConcat:

Load

    Fld1 as t_Fld1,

    RowNo() as indx,

    Mid(Fld1,iterNo(),1) as t_Fld1Rev2

resident data while iterNo() <= len(Fld1);

FinalConcat:

LOAD t_Fld1 as Fld1,

    Concat(t_Fld1Rev2,'',-indx) as Fld1Rev2

resident TmpConcat

Group by t_Fld1;

flipside

shayraber
Creator
Creator
Author

also good solution.

a shorter script will look like this:

function Reverse(FIELD)

Reverse=strreverse(FIELD)

end function

and then, simply: Reverse (Field) as Field

fabio182
Creator II
Creator II

Excelent !!!