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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
mcornips
Contributor III
Contributor III

Create a new field in the LOAD-statement

Dear all,

I want to create a new field in the load-statement which value should be equal to the name of the table. This is the table where the LOAD-statement refers to.

Regards,

Maurice

8 Replies
buzzy996
Master II
Master II

whr is ur table?

may be,

tab3:

Load * Inline [

dim1,dim2

-4,0

-2,0.2

0,0.4

2,0.6

4,0.8

];

Tba2:

NoConcatenate load

dim1,

dim2,

'Tba2' as Tba2

Resident tab3;

drop table tab3

sunny_talwar

You can use TableName() function like this:

Table:

LOAD * INLINE [

    Dim, Value

    A, 10

    B, 20

    C, 10

];

Join(Table)

LOAD *,

  TableName(0) as TableName

Resident Table;

Output:

Capture.PNG

mcornips
Contributor III
Contributor III
Author

My Load statement is as follows:

LOAD Date,

    Value1,

    Value2;

    SQL SELECT *

FROM `OS1`;

Now I want to create a new field (Tablename) which always shows the value OS1

sunny_talwar

Try this as buzzy996 mentioned

OS1:

LOAD Date,

    Value1,

    Value2,

    'OS1' as Tablename;

    SQL SELECT *

FROM `OS1`;

or use this for what I mentioned:

OS1:

LOAD Date,

    Value1,

    Value2;

    SQL SELECT *

FROM `OS1`;

Join(OS1)

LOAD *,

          TableName(0) as Tablename // 0 within parenthesis will depend on which table number it is in your load where first table = 0, second = 1, third = 2 and so on...

Resident OS1;

HTH

Best,

Sunny

mcornips
Contributor III
Contributor III
Author

Thank you Sunny, this works.

But actually I would like to use the tablename of the source database.

Like this:

Substation:

LOAD Date,

    Value1,

    Value2,

    'OS1' as Tablename;

    SQL SELECT *

FROM `OS1`;

sunny_talwar

I am not sure if I know how to do that. Might be somebody else knows how to do it

Best,

Sunny

mcornips
Contributor III
Contributor III
Author

Thank you, with your answers I can continue anyway.

Best,

Maurice

sunny_talwar

That's true , but I still hope that you find a better solution