Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a '.txt' file with some fields which are loaded to qlik view without problem.
The '.txt' file name is 'REAL_2015_12'.
When I load the file I would like to know how to add (in addition to the fields loaded from the file), three more fields:
Field named 'Scenario' containing the unique value 'REAL'
Field named 'Year' containing the unique value '2015'
Field named 'Period' containing the unique value '12'
How coulda I do tihs?
Thanks
May be this:
LOAD *,
'REAL' as Scenario,
2015 as Year,
12 as Period
FROM REAL_2015_12.txt
Or if this need to be grabbed from the filename itself, then this:
LOAD *,
SubField(FileName(), '_', 1) as Scenario,
SubField(FileName(), '_', 2) as Year,
Replace(SubField(FileName(), '_', 3), '.txt', '') as Period
FROM REAL_2015_12.txt
May be this:
LOAD *,
'REAL' as Scenario,
2015 as Year,
12 as Period
FROM REAL_2015_12.txt
Or if this need to be grabbed from the filename itself, then this:
LOAD *,
SubField(FileName(), '_', 1) as Scenario,
SubField(FileName(), '_', 2) as Year,
Replace(SubField(FileName(), '_', 3), '.txt', '') as Period
FROM REAL_2015_12.txt
LOAD
*,
subfield(Filebasename(),'_',1) as Scenario,
subfield(Filebasename(),'_',2) as Year,
subfield(Filebasename(),'_',3) as Period
FROM
REAL_2015_12.txt (....etc)
;
The second option thanks a lot to everybody.