Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

syntax to add a condition

Hi all,

I need to add a condition to a field which is part of the LINKKEY field (Not sure why initially in one qvd LINKKEY is defined in LOAD part and in another in SELECT part).

QVD1---------------------------------------------------------------------------------------

condition to add:

           if D_ASSET_TYPE = '005' and A_DEPT < '1000' then A_DEPTFUNC = '000'

QVD1:

LOAD
A_DEPT,
F_FUND,
A_DEPTFUNC,
D_ASSET_TYPE,
A_SUBDEPT,
LINKKEY;

SQL SELECT
A_DEPT,
F_FUND,
A_DEPTFUNC,
D_ASSET_TYPE,
A_SUBDEPT,
A_DEPT || '-' || F_FUND || '-' || A_DEPTFUNC || '-' || D_ASSET_TYPE || '-' || A_SUBDEPT as LINKKEY
FROM YYYY;

store QVD1 into '..\QVDs\QVD1.qvd';


QVD2---------------------------------------------------------------------------------------

condition to add:

            if ASSET_TYPE = '005' and DEPT < '1000' then DEPTFUNC = '000'

QVD2:
LOAD
    DEPT,
    DEPTFUNC,
    DEPT & '-' & FUND & '-' & DEPTFUNC & '-' & ASSET_TYPE & '-' & SUBDEPT as LINKKEY,
    DEPT & '-' & DEPTFUNC & '-' & SUBDEPT as DEPTPROJKEY,
SQL SELECT
     DEPT,
     DEPTFUNC,
FROM AAAA;
store QVD2 into '..\QVDs\QVD2.qvd';

Thanks, appreciate your help

Tags (1)
7 Replies

Re: syntax to add a condition

May be this:

QVD1:

LOAD
A_DEPT,
F_FUND,
A_DEPTFUNC,
D_ASSET_TYPE,
A_SUBDEPT,
DEPT & '-' & FUND & '-' & If(D_ASSET_TYPE = '005' AND A_DEPT = <1000, '000', DEPTFUNC) & '-' & ASSET_TYPE & '-' & SUBDEPT as LINKKEY;

SQL SELECT
A_DEPT,
F_FUND,
A_DEPTFUNC,
D_ASSET_TYPE,
A_SUBDEPT,
A_DEPT || '-' || F_FUND || '-' || A_DEPTFUNC || '-' || D_ASSET_TYPE || '-' || A_SUBDEPT as LINKKEY
FROM YYYY;

store QVD1 into '..\QVDs\QVD1.qvd';

QVD2:

LOAD

    DEPT,

    DEPTFUNC,

    DEPT & '-' & FUND & '-' & If(D_ASSET_TYPE = '005' AND A_DEPT = <1000, '000', DEPTFUNC) & '-' & ASSET_TYPE & '-' & SUBDEPT as LINKKEY,

    DEPT & '-' & DEPTFUNC & '-' & SUBDEPT as DEPTPROJKEY,

SQL SELECT

     DEPT,

     DEPTFUNC,

FROM AAAA;

store QVD2 into '..\QVDs\QVD2.qvd';

Not applicable

Re: syntax to add a condition

Sunny,

looks like we can not condition within select statement?

Re: syntax to add a condition

That would be a question to ask a SQL guy. Don't have too much expertise there.

krishna_2644
Valued Contributor III

Re: syntax to add a condition

Hi Larisa,

Try below:

QVD1:

LOAD
A_DEPT,
F_FUND,
A_DEPTFUNC,
D_ASSET_TYPE,
A_SUBDEPT,
LINKKEY;

SQL SELECT
A_DEPT,
F_FUND,
A_DEPTFUNC,
D_ASSET_TYPE,
A_SUBDEPT,
A_DEPT || '-' || F_FUND || '-' || A_DEPTFUNC || '-' || D_ASSET_TYPE || '-' || A_SUBDEPT as LINKKEY
FROM YYYY

WHERE D_ASSET_TYPE = '005' and A_DEPT < '1000' AND A_DEPTFUNC = '000';

//(if you want all the conditions to be satisfied at once else you can use 'OR' instead of 'AND')

store QVD1 into '..\QVDs\QVD1.qvd';


QVD2---------------------------------------------------------------------------------------

QVD2:

LOAD
    DEPT,
    DEPTFUNC,
    DEPT & '-' & FUND & '-' & DEPTFUNC & '-' & ASSET_TYPE & '-' & SUBDEPT as LINKKEY,
    DEPT & '-' & DEPTFUNC & '-' & SUBDEPT as DEPTPROJKEY,
SQL SELECT
     DEPT,
     DEPTFUNC,
FROM AAAA

where ASSET_TYPE = '005' and DEPT < '1000' and DEPTFUNC = '000';


store QVD2 into '..\QVDs\QVD2.qvd';

Not applicable

Re: syntax to add a condition

Thank you Sunny for your help, it works.  

Not applicable

Re: syntax to add a condition

Thanks a lot, problem fixed.

L

krishna_2644
Valued Contributor III

Re: syntax to add a condition

Please close the thread

Community Browser