Reverse String ⏪

Danny Roden
Danny Roden Administrator
edited December 2023 in Functions library

Reverse String

If you find yourself needing to reverse a string (i.e. for bespoke building of anonymisation logic or so as you can sort on suffix) then this function may be of use to you.

The function simply reverses the input (as in displays it in backwards sequence) character-for-character (e.g. "Danny R" becomes "R ynnaD").

See below for a screenshot of the function and some sample results:

Note: As you will see from the above, the logic involves splitting each character into a list and using the native 'list' functions to do the heavy lifting. In order to get around 'space' and 'comma' characters which may otherwise impact results I've replaced them at the beginning with a rarely used set of characters (which are then added back at the end). If your input happens to contain the dagger '†' or double dagger '‡' characters then this will affect the results).


This function is compatible with all instances of Data Studio from v2.1.11 onwards.