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

Add extra field in QV Table

Hi together,

I am new in Qv and now I have the following problem:

I have two SQL Tables with the same fields. I load them in QV and then I want to join thel in one table (I think it should not be a problem as they have same fields) but before joining I want to add one field for the first one and one for the second and I want this field to have user defined value(I want to define the value in the csript, not with input field). For example I have one table with customers and one with suppliers and when I join the tables in QV I want to have a field with info which record is customer and which is supplier.

Thanks in advance!

5 Replies
Not applicable
Author

hello plss , provide you problem clearly.

Moeover u can alias or rename field name in qvw.

Not applicable
Author

I will give an example:

CustomerTable:

ID Name Address

1 CSCS New York

2 DDDD Chicago

SupplierTable:

ID Name Address

1 FGFGF New York

2 DSRYJ Chicago



So I want to join them in this way:

ID Name Address

1 FGFGF New York

2 DSRYJ Chicago

1 CSCS New York

2 DDDD Chicago



but I want to add extra field, so it look like this:



Type ID Name Address

Supplier 1 FGFGF New York

Supplier 2 DSRYJ Chicago

Customer 1 CSCS New York

Customer 2 DDDD Chicago



Miguel_Angel_Baeyens

Hello,

There are several ways to do that. If both tables are not related but you want them to be just one table, you can concatenate them:

Table:LOAD *, 'Customers' AS RECORD_TYPE;SQL SELECT *FROM Table;CONCATENATE // Not needed if both tables have exactly same number and names of fieldsLOAD *, 'Suppliers' AS RECORD_TYPE;SQL SELECT *FROM Tabl2;


This will append Suppliers data to Customers data. If they are related (say Invoice headers and lines) you can join them

InvoiceData:LOAD *, Year & '/' & InvoiceNo AS DOCUMENT_NO;SQL SELECT *FROM InvoiceHeaders;JOINLOAD *, Year & '/' & InvoiceNo AS DOCUMENT_NO;SQL SELECT *FROM InvoiceLines


You can use any QlikView function to create new fields in your LOAD statement.

Hope that helps.

Not applicable
Author

Hi,

If i understood your question properly. Below is the code.

Load Id,

Name,

Address

'Customer' as Type

From Customer_Table;

CONCATENATE

Load Id,

Name,

Address

'Supplier' as Type

From Supplier_Table;

Hope this may help you.

- Sridhar

Not applicable
Author

Thank You very much. It works. This was really stupid question, but as I said I am new in QV.

Thanks