Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Qlikers,
I have a table like-
Lib connect to 'Data Source'
Load
Source1_id,
Source1_name,
Source1_address,
Source1_date;
[Table]:
Select *
From 'data';
I want to remove Source1_ from all the fields.
Does this have any solution?
Kind Regards
T25:
Load * inline [
Source1_id, Source1_name, Source1_address, Source1_date
1,2,3,4
];
for j=1 to NoOfFields('T25')
let vFieldName = FieldName($(j),'T25');
let vMatch = wildmatch('$(vFieldName)', 'Source1_*');
TRACE $(vFieldName) $(vMatch);
if $(vMatch) then
LET vNewFieldName = RIGHT('$(vFieldName)', LEN('$(vFieldName)') - LEN('Source1_') );
TRACE 'RENAME $(vFieldName)' '$(vNewFieldName)';
RENAME Field [$(vFieldName)] TO [$(vNewFieldName)];
ENDIF
NEXT
T25:
Load * inline [
Source1_id, Source1_name, Source1_address, Source1_date
1,2,3,4
];
for j=1 to NoOfFields('T25')
let vFieldName = FieldName($(j),'T25');
let vMatch = wildmatch('$(vFieldName)', 'Source1_*');
TRACE $(vFieldName) $(vMatch);
if $(vMatch) then
LET vNewFieldName = RIGHT('$(vFieldName)', LEN('$(vFieldName)') - LEN('Source1_') );
TRACE 'RENAME $(vFieldName)' '$(vNewFieldName)';
RENAME Field [$(vFieldName)] TO [$(vNewFieldName)];
ENDIF
NEXT
Thank you so much Mxgro, it worked the way I wanted.
Now, can I add 'S1_' as prefix on all renamed fields?
Like, S1_id
Kind Regards
try with
LET vNewFieldName = 'S1_' & RIGHT('$(vFieldName)', LEN('$(vFieldName)') - LEN('Source1_') );