Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
This should be simple for anyone who has done this before.
I have an 8 char code (UCODE) that if the first position is a "P", I want to strip the P from the code and keep the remaining char's and move everything to the left one space. Can someone provide the syntax for that? I have tried many examples and cannot get any to work Thank you in advance.
I think the definite reference is the Qlik Help section describing functions:
I can explain my example:
left(UCODE,1) = The first character in UCODE from the left.
PurgeChar(left(UCODE,1),'P') = Return a string consisting of he first character in UCODE from the left with 'P' purged. So if it's a P an empty string is returned, otherwise the first letter of UCODE.
mid(UCODE,2) = The string UCODE starting from the second character until the end.
The & concatenates the two strings
PurgeChar(left(UCODE,1),'P')&mid(UCODE,2)
If you were positive that UCODE could only contain a P in the first position it would be even simpler. Then PurgeChar(UCODE, 'P') would be fine.
hi
you cna try
=if(left(UCODE,1)='P',right(UCODE,7),UCODE)
If(Left(UCODE,1)='P', mid(UCODE,2), UCODE)
try,
load *,
if(left(UCODE,1)='P', purgechar(UCODE,'P'),UCODE) as UCODE
From Table
Hi,
Try this
if(left(UCODE,1)='P',TRIM(MID(UCODE,2,LEN(UCODE))),UCODE)
Many ways to get what you want. One without an if:
PurgeChar(left(UCODE,1),'P')&mid(UCODE,2)
Thanks to all. Since I am a newbie, the biggest challenge that I face is reference material that describes each function and what the keywords mean. I go back and forth between the Qlik Help and the reference manual and don't know what "MID" means in this example (just an example)
if(left(UCODE,1)='P',TRIM(MID(UCODE,2,LEN(UCODE))),UCODE)
You have probably faced this before so if anyone has suggestions on the best function syntax/keyword document I am all ears. I use the Qlik community as well but most of the examples are similar to what I am looking for but not exact. Thank you again for any assistance.
I think the definite reference is the Qlik Help section describing functions:
I can explain my example:
left(UCODE,1) = The first character in UCODE from the left.
PurgeChar(left(UCODE,1),'P') = Return a string consisting of he first character in UCODE from the left with 'P' purged. So if it's a P an empty string is returned, otherwise the first letter of UCODE.
mid(UCODE,2) = The string UCODE starting from the second character until the end.
The & concatenates the two strings
PurgeChar(left(UCODE,1),'P')&mid(UCODE,2)
If you were positive that UCODE could only contain a P in the first position it would be even simpler. Then PurgeChar(UCODE, 'P') would be fine.
Hi,
You can try this:
=if(left(vMyName,1)='P', right(vMyName,len(vMyName)-1),vMyName)
Hi,
another solution could be:
Mid(UCODE,1-(UCODE like 'P*'))
LOAD *,
Mid(UCODE,1-(UCODE like 'P*')) as UCODE2
INLINE [
UCODE
P1234567
12345678
A3456789
B4567890
98765432
P56789012
PDSFGSDF
DFGDGSDFGD
PEWRTWET
];
hope this helps
regards
Marco