Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Highlighted
New Contributor II

Adding a flag to each entry in a Table to identify table name

Hi,

I'm loading in data from several tables in Qlik Sense from an ORACLE database, e.g. one table called APPLES and another called ORANGES. What I'm trying to do is create a flag called [ASSET TYPE] that would read "Apples" if coming from the APPLES table and "Oranges" if from the ORANGES table to give me one output.

Any ideas how I might create something like this?

Many thanks,

Sarah

    

ASSET IDASSET TYPEASSET NAMEREGION COUNTRY
X1234ApplesGranny SmithEMEAUK
X0154ApplesPink LadyEMEASpain
X1857OrangesSatsumaLATAMBrazil
X1095OrangesMandarinEMEASpain

LIB CONNECT TO [Oracle_abc.com]

[APPLES]:

LOAD [ASSET ID]

,[ASSET NAME]

,[REGION]

,[COUNTRY]

; SELECT "ASSET ID"

,"ASSET NAME"

,"REGION"

,"COUNTRY"

FROM APPLES;

[ORANGES}:

LOAD [ASSET ID]

,[ASSET NAME]

,[REGION]

,[COUNTRY]

; SELECT "ASSET ID"

,"ASSET NAME"

,"REGION"

,"COUNTRY"

FROM ORANGES;

Tags (1)
4 Replies
Highlighted

Re: Adding a flag to each entry in a Table to identify table name

May be like this

[APPLES]:

LOAD [ASSET ID]

,[ASSET NAME]

,[REGION]

,[COUNTRY]

; SELECT "ASSET ID"

,"ASSET NAME"

,"REGION"

,"COUNTRY"

,'Apples' as [ASSET TYPE]

FROM APPLES;

[ORANGES}:

LOAD [ASSET ID]

,[ASSET NAME]

,[REGION]

,[COUNTRY]

; SELECT "ASSET ID"

,"ASSET NAME"

,"REGION"

,"COUNTRY"

,'Oranges' as [ASSET TYPE]

FROM ORANGES;

Highlighted
New Contributor II

Re: Adding a flag to each entry in a Table to identify table name

Hi Sunny,

many thanks for this suggestion - I had tried using a script similar to what you had suggested but was using double quotes instead of your single ones. I replaced this with single quotes in the SELECT part of the statement, e.g.

'Apples' as [ASSET TYPE] but I'm getting the following error message:

The following error occurred:

Connector reply error: ***

Could this be something to do with the fact that I'm trying to connect directly to an Oracle DB?

Many thanks,

Sarah

Highlighted

Re: Adding a flag to each entry in a Table to identify table name

Are you doing Direct Discovery?

Highlighted
New Contributor II

Re: Adding a flag to each entry in a Table to identify table name

Hello Sarah, check the syntax for a missing square-brace that wraps the table name.



Sarah Kebbell wrote:

[ORANGES}:  //<~ missing end square-brace

LOAD [ASSET ID]

,[ASSET NAME]

,[REGION]

,[COUNTRY]

; SELECT "ASSET ID"

,"ASSET NAME"

,"REGION"

,"COUNTRY"

FROM ORANGES;