Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Loading a static string with Load statement

Hi guys,

I have a load statement like

[Txn]:

Load

TxnId,

From invoice.qvd(qvd);

Concatenate(Txn)

Load

TxnId,

From SalesReceipt.qvd(qvd);

These QVD files have only one column.

But I want my table to look like this

TxnType          TxnId

Invoice,                1

Invoice,                2

SalesReceipts      3

So it means I need to insert a hard coded value for each Load;

something like this

[Txn]:

Load

TxnId,

"Invoice" as TxnType

From invoice.qvd(qvd);

Concatenate(Txn)

Load

TxnId,

"SalesReceipt" as TxnType

From SalesReceipt.qvd(qvd);

But obviously it will not work becasue it will not find Invoice or SalesReceipt column in respective QVD files.

How to do this?

Thanks,

Saurabh

1 Solution

Accepted Solutions
peter_turner
Partner - Specialist
Partner - Specialist

Hello Saurabh,

I think you answered your own question as the last example should work ok.

You may need to replace the double quotes with a single quote, but you will end up with a new field called TxnType with either 'Invoice' or 'SalesReceipt' as the value.

View solution in original post

6 Replies
salto
Specialist II
Specialist II

Hello,

if the above solution does not work, I would try:

[TxnTemp]:

Load

TxnId,

From invoice.qvd(qvd);

[Txn]:

Load

     *,

     "Invoice" as TxnType resident TxnTemp;

drop table TxnTemp;

[TxnTemp]:

Load

TxnId,

From SalesReceipt.qvd(qvd);

Load

      *,

     "SalesReceipt" as TxnType resident TxnTemp;


drop table TxnTemp;


HTH.

peter_turner
Partner - Specialist
Partner - Specialist

Hello Saurabh,

I think you answered your own question as the last example should work ok.

You may need to replace the double quotes with a single quote, but you will end up with a new field called TxnType with either 'Invoice' or 'SalesReceipt' as the value.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Your script is fine except that Invoice and SalesReceipt should be in single quotes.

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Anonymous
Not applicable
Author

Hi,

considering peter's answer your script looks like :

[Txn]:

Load

     TxnId,

     'Invoice' as TxnType

From invoice.qvd(qvd);

Concatenate(Txn)

Load

     TxnId,

     'SalesReceipt' as TxnType

From SalesReceipt.qvd(qvd);

Not applicable
Author

Thanks Peter!

It works.

Not applicable
Author

Thanks Jonathan,

It works.

I marked Peter's answer as correct because I got his reply earlier than yours.