Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Im trying to take a value eg. 123456789 and get a new value with the same digits but backwards ( so ill be getting 987654321). Does anyone know how to do this because ive tried using replace(index but im not successful.
Any help is appreciated, thanks in advance
Hi, i've made this macro
Function reverse(t)
r = ""
For i = len(t) to 1 step -1
r = r & mid(t,i,1)
next
reverse = r
end Function
And you can call it from the script
LOAD
*,
reverse(F1) as F1_reverse
INLINE [
F1
123456789
];
It works for me, can you try it?
Rgds
Hi, i've made this macro
Function reverse(t)
r = ""
For i = len(t) to 1 step -1
r = r & mid(t,i,1)
next
reverse = r
end Function
And you can call it from the script
LOAD
*,
reverse(F1) as F1_reverse
INLINE [
F1
123456789
];
It works for me, can you try it?
Rgds
Thanks for the step in the right direction, yeah ive got it working however I trying use it for a field so when i use a field, the field name appears backwards instead of the value.
Hi again
Please note that reverse(F1) is different of reverse('F1')
For the first case, the function will reverse the value of the field F1 and you can put an alias to name it, and in the second one it's going to reverse the text "F1", so the function will return "1F"
is this your problem?
Rgds
Hi,
Basically in ur example you have used 123456789 as just plain text, im trying to change that 123456789 to a field from a qvd. so basically what my code shows
LOAD
*
,
reverse
(F1) asF1_reverse
INLINE
[ FI
CI_PER.PER_ID
; but the function is taking the text CI_PER.PER_ID and changing it to DI_REP.REP_IC instead to taking the value of that field
Hi
The inline table was just an example for the functionallity and it's application, you need to use the function inside the load of your QVD file, i mean
Load
Field1,
Field2,
reverse(Field2) as Reverse_Field2
....
From QvdFile.qvd (qvd);
You can use the function reverse in the same way you use other qlikview functions like year(), month(), applymap() etc
Rgds
Yeah I got that working now, thanks alot for your help. Your a legend
No problem 😉
greetings
Hi,
Could you indicate how to declare this script inside the load statement of QV?
I am trying to have it in a include file, without much success.
Thanks,
Antoine