Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Community,
I need help with loading just part of a string.
e.g. I have a string in the database which is "001.02" or "001-02".
When loading this into qlikview i just want to get "001" as a result - so only the left part before "." or "-".
I am sure this is very simple but I do not know which expression is needed.
Thanks in advance for help!
Best regards
Robert
May be this:
If(KeepChar(FieldName, '.-') = '.', SubField(FieldName, '.', 1), SubField(FieldName, '-', 1))
Is there only two separator "." and "_" or there is any other separator?
Hi Robert,
Use SubField like this:
=SubField('001-02', '-', 1)
Put instead of '-' with '.' if you have '001.02'.
Sunny T response works like a charm also
Regards,
MB
if there is only two separator then try like this
subfield(replace(replace(String,'.','*'),'-','*'),'*',1) as String_New
LOAD *, subfield(replace(replace(String,'.','*'),'-','*'),'*',1) as String_New Inline [
String
001.002
002_003
003.004];
or even simpler:
=Subfield(Replace(String, '.', '-'), '-', 1)
or in script:
...Subfield(Replace(String, '.', '-'), '-', 1) AS String_New, ...