Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

i am new to QlikView. Want to make a querry for XYZ column

Want to make a querry for XYZ column for below condition.

we have three fields vat1, vat2, vat3.

xyz is vat1 if only numeric value for vat1 exists

xyz is vat3 if vat3 exists

xyz is vat2 if vat2 exists

3 Replies
Gysbert_Wassenaar

Something like this:

load

     vat1

     , vat2

     , vat3

     , if(isnum(vat1), vat1, if(len(trim(vat3))>0,vat3,if(len(trim(vat2))>0,vat2))) as XYZ

from ...mysource...;


talk is cheap, supply exceeds demand
alexandros17
Partner - Champion III
Partner - Champion III

TAB:

SELECT * From MyTable;

TABFINAL:

Load

     *,

     if(isnum(vat1)),num(vat1), if(not isnull(vat2), vat2, vat3)) as xyz

resident TAB;

drop table TAB;

Anonymous
Not applicable
Author

you may have to elaborate a bit more. in your example, what if more than one condition is true? what would the result be? if the conditions are sequential - check for 2 if 1 is not satisfied, etc. then following should help:

in your load statement, you can add the following:

load

     vat1,

     vat2,

     vat3,

     if(isnum(vat1),vat1,if(isnull(vat2),if(isnull(vat3),0,vat3),vat2)) as xyz

from

...;

replace 0 in the above expression with the answer to what if none of the conditions are satisfied.