Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
bobbydave
Creator III
Creator III

Extracting date and not text

SourceData:

  first 1

  LOAD

  //subfield(FileName(),'CPS_',2) as XLS_SourceSB

  left(right(subfield(FileName(),'CPS_',2),25),6)  as XLS_SourceSB

  FROM    

[$(vDGD)\CPS_TIA_V_Off_Sys_Figs_$(vcurrentyear)*.xlsx]

(ooxml, embedded labels, table is [CPS_TIA_V_Off_Sys Figs]);

Filenames:

CPS_TIA_V_Off_Sys_Figs_201609.xls

CPS_TIA_V_Off_Sys_Figs_LATAM_201606.xls

I am trying to extract the dates from the above filename but i dont want the LATAM filename. How do I get around this in order to ensure that XLS_SourceSB takes in the YYYYMM (201609) and NOT LATAM.?

1 Solution

Accepted Solutions
Anil_Babu_Samineni

Perhaps this?

=Left(SubField(FieldName, '_', -1), 6)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

6 Replies
Chanty4u
MVP
MVP

try this in ur script

  SubField(FileBaseName(),'_',7) as new,

Anil_Babu_Samineni

Perhaps this?

=Left(SubField(FieldName, '_', -1), 6)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
woshua5550
Creator III
Creator III

I think this would work

KeepChar(FileName(),'0123456789') as XLS_SourceSB

bobbydave
Creator III
Creator III
Author

This will only take the first file name and not the filename containing LATAM?

Anil_Babu_Samineni

This should work until unless Different string like

CPS_TIA_V_Off_Sys_Figs_LATAM_201606_ABC.xls

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
bobbydave
Creator III
Creator III
Author

Yes the LATAM filename will always be in the same format so this is perfect if it ignores it and will now only consider the other filename.

Thanks