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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Direct Discovery Query

Hi All,

Please let me know how to code this in qlikview , 

CASE WHEN  cs.alt_wrkr_id='Y'

           THEN hw.alt_wrkr_id

ELSE 'XXXXXX' END AS alt_wrkr_id

the below sample code  is working fine , but i need to add the above condtion in to the below code

DIRECT QUERY

DIMENSION

Table1.hcmcore_wrkr_key

FROM Table1.hcmcore_worker

Thanks in advance

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

You should be able to use the NATIVE() function that is supported in a DIRECT QUERY statement:

NATIVE data-source syntax can be used when the user knows the database to be queried and wants to exploit database-specific extensions to SQL. NATIVE data-source syntax is supported:

    • As field expressions in DIMENSION and MEASURE clauses
    • As the content of the WHERE clause

Probably like this:

       NATIVE('CASE WHEN  cs.alt_wrkr_id=''Y'' THEN hw.alt_wrkr_id ELSE ''XXXXXX'' END') AS alt_wrkr_id

        NOTE: the '' above is two consecutive single quotes and not a double quote

OR

       NATIVE('CASE WHEN  cs.alt_wrkr_id=' & Chr(39) & 'Y' & Chr(39) &' THEN hw.alt_wrkr_id ELSE ' & Chr(39) &'XXXXXX' & Chr(39) &'  END') AS alt_wrkr_id

The last option is necessary in older versions of QlikView Prior to QlikView November 2017 I believe.

View solution in original post

4 Replies
petter
Partner - Champion III
Partner - Champion III

You should be able to use the NATIVE() function that is supported in a DIRECT QUERY statement:

NATIVE data-source syntax can be used when the user knows the database to be queried and wants to exploit database-specific extensions to SQL. NATIVE data-source syntax is supported:

    • As field expressions in DIMENSION and MEASURE clauses
    • As the content of the WHERE clause

Probably like this:

       NATIVE('CASE WHEN  cs.alt_wrkr_id=''Y'' THEN hw.alt_wrkr_id ELSE ''XXXXXX'' END') AS alt_wrkr_id

        NOTE: the '' above is two consecutive single quotes and not a double quote

OR

       NATIVE('CASE WHEN  cs.alt_wrkr_id=' & Chr(39) & 'Y' & Chr(39) &' THEN hw.alt_wrkr_id ELSE ' & Chr(39) &'XXXXXX' & Chr(39) &'  END') AS alt_wrkr_id

The last option is necessary in older versions of QlikView Prior to QlikView November 2017 I believe.

Anonymous
Not applicable
Author

Hi Peter,

Thanks for the reply , awesome

NATIVE('CASE WHEN  cs.alt_wrkr_id=''Y'' THEN hw.alt_wrkr_id ELSE ''XXXXXX'' END') AS alt_wrkr_id

code worked like a charm

petter
Partner - Champion III
Partner - Champion III

You're welcome

Anonymous
Not applicable
Author

Hi Peter ,

Is it possible to use QVD and Direct Query in  a Qvw 

example

Table1:

Load * from Qvd1.qvd(qvd);

Table2:

DIRECT QUERY

DIMENSION

Table1.hcmcore_wrkr_key

FROM Table1.hcmcore_worker

Thanks in advance