Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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
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
Excelent !!!