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

reverse string in Qlik Sense

Hi All,

when using QV i am using a macro code to reverse a string,

how can i do this in Qlik Sense?

because there is no macro in Qlik Sense.

Thanks.

4 Replies
Gysbert_Wassenaar

This should work:Reverse string


talk is cheap, supply exceeds demand
idogridish2
Creator II
Creator II
Author

Thanks a lot Gysbert Wassenaar,

but is there a function you know that i can wrap the field with?

like flip(mytext)?

and if not, is there a way to build something like this?

idogridish2
Creator II
Creator II
Author

because if i need to reverse two fields in my table i need to read the table twice,

and by looking at the code the table is expended as the length of "mytext" field and than shranked to her previous size.

Many thanks again.

Gysbert_Wassenaar

No and not as far as I know.

Perhaps you can do something like this:

Strings:

LOAD distinct MyText1 as String FROM source;

CONCATENATE (Strings)

LOAD distinct MyText2 as String FROM source;

..etc...

mapStrings:

MAPPING

LOAD String, concat(Letter,'',-row) as ReversedString GROUP BY String;

LOAD String, iterno() as row, mid(String,IterNo(),1) As Letter

While IterNo() <= len(String);

DROP TABLE Strings;

Result:

LOAD

     MyText1,

     ApplyMap('mapStrings',MyText1) as 1texTyM,

     MyText2,

     ApplyMap('mapStrings',MyText2) as 2texTyM,

     ...other fields

FROM

     source

     ;


talk is cheap, supply exceeds demand