Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am loading a qlik qvd and all the fields have a prefix.
Example:
Load
Sales.SalesID,
Sales.SalesPerson,
Sales.Item,
Sales.Cost
FROM [lib://Example/Sales.qvd] (qvd);
I thought that I could perhaps name the table Sales and then use Unqualify *; but it didn't work.
Any other possible solutions?
Hi
Sadly i can't thing of easy answer, you would be able to probably write a loop with variables to do it, but probably more work that it is worth.
If i was working on this would be questioning why it is getting qualified in the first place and maybe address this is the app outputting the QVD?
Might be, try with rename fields with Mapping table
A dirty hack but quick.
Copy your load script into Excel
=CONCAT(SUBSTITUTE(I14,",",""), " AS ", TRIM(SUBSTITUTE(SUBSTITUTE(I14,",",""), "Sales.","")))
If you are still looking for an automated solution, here is a subroutine to process this type of issue.
sub Removefieldnameprefix (delimiter,table)
Let vdelimiter = '$(delimiter)';
Let vtable = '$(table)';
Let vNoFields = NoOfFields('$(vtable)');
for a = 1 to $(vNoFields)
Let vFieldname = FieldName($(a),'$(vtable)');
Let vIndex = len(subfield('$(vFieldname)','$(vdelimiter)',1))+1;
Let vlen = len('$(vFieldname)')-$(vIndex);
FieldMap:
Mapping
Load
'$(vFieldname)' as oldname,
right('$(vFieldname)',$(vlen)) as newname
AutoGenerate 1;
next a;
Rename Fields using FieldMap;
end sub;
Call Removefieldnameprefix (your_delimiter,yourtablename)
// for example
//call Removefieldnameprefix ('_','parkmobile_daily_transaction');
Hope it helps.