Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Simple Question: Automatic generation of the table name with the field name

Hi,

I ask you a simple question, I just want to load my QVD's without automatic generation of his name, with the fields.
Note: I have not added any manipulation script, it's automatic and it's only on some applicables QVD (tables).


Example:

Case: QVD_Name.NameField

I just want to load my QVD without "BillingDocumentLinesTemp" automatically. Because I tried to  rename it ( all fields) with " as " but it still have a different name.

Goal: Only NameField

90.PNG.png


It's very Urgent, Thanks for your Help!

12 Replies
flipside
Partner - Specialist II
Partner - Specialist II

Hi,

If it's the fields you need to rename, then I would build a mapping table from the QVD Metadata something like this ...

 

Let removeString='BillingsDocumentsLinesTemp.';

FieldNameMap:
Mapping LOAD
FieldName as OldFieldName,
If(left(FieldName,len('$(removeString)'))='$(removeString)',subfield(FieldName,'$(removeString)',-1)) as NewFieldName

FROM [???.qvd] (XmlSimple, Table is [QvdTableHeader/Fields/QvdFieldHeader]);

Data:
LOAD * FROM
[???.qvd]] (
qvd);

Rename Fields using FieldNameMap;

Maybe building a subroutine so you can call it and pass different removeString parameters for other QVDs would suit.

flipside

salto
Specialist II
Specialist II

Hi,

I have tried this and works for me:

After loading the first table (being a QVD or not):

LET QVDNumber = 0;

After Loading every table (being a QVD or not):

LET QVDNumber = $(QVDNumber) +1;

After loading every QVD table:

LET OldName = TableName($(QVDNumber));

LET NewName = subfield(TableName($(QVDNumber)), '.',2);

rename table $(OldName) to $(NewName);

I am sure this code can be more elegant, using the TableNo() function

Not applicable
Author

Hi SALTO,

Yess, I tried to apply your code and it works very well

A lot of Thanks!!

Results:

0.PNG.png