Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Case When

I have two tables stored as QVDs, see below. In SQL server I would create the below script to get my desired results. How can I write this in QV? Unfornutely, I cannot write the script in SQL server becuase my two tables are loaded on different serves and I cannot join to multiple servers for policy reasons.

,CASE WHEN DATEDIFF(DD,A.CreatedDate, B.UpdatedDate) > 3 THEN 'N'

  ELSE 'Y' END 'Indicator'

QVDs:

table 1                 table2

CreatedDate         UpdatedDate

ID                          ID

1 Solution

Accepted Solutions
kumarkp412
Creator II
Creator II

hi John,

Load these two tables in QV and join them using ID.

Just try the below script in QV.

Temp:

Load

CreatedDate,

ID

from table1.QVD

Join()

Load

updatedDate,

ID

from table2.QVD

Final:

Load

ID

if(interval(CreatedDate-UpdatedDate,'d')>3,N,Y) Indicator

resident Temp;

Thanks

Kumar kVP

View solution in original post

6 Replies
marcus_sommer

Maybe in this way:

qvd:

load ID, CreatedDate From qvd1;

     join

load ID, UpdatedDate From qvd2;

final:

load *, if(UpdatedDate - CreatedDate > 3, 'N', 'Y') as Indicator resident qvd;

drop table qvd;

- Marcus

kumarkp412
Creator II
Creator II

hi John,

Load these two tables in QV and join them using ID.

Just try the below script in QV.

Temp:

Load

CreatedDate,

ID

from table1.QVD

Join()

Load

updatedDate,

ID

from table2.QVD

Final:

Load

ID

if(interval(CreatedDate-UpdatedDate,'d')>3,N,Y) Indicator

resident Temp;

Thanks

Kumar kVP

Anil_Babu_Samineni

You may try this

load *, if(interval(UpdatedDate - CreatedDate) > num(makedate(3)), 'N', 'Y') as Indicator resident qvd;

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
trdandamudi
Master II
Master II

You can also do this on the front end as below:

Load * from Table1

Concatenate

Load * from Table2

Straight chart:

Dimensions:

ID,

CreateData

UpdatedDate

Expression:

If(UpdatedDate-CreatedDate>3,'N','Y')

Anonymous
Not applicable
Author

Thank you for all the feedback. This is what I have so far, cannot quite get the syntax correct but understand the idea.

qvd1:

sql

select * from TableA;

Store qvd1 INTO $vPath_QVDs)qvd1.qvd(qvd);

//////////////////////////////////////////////////////////////////////////

qvd2:

sql

select * from TableB;

Store qvd2 INTO $vPath_QVDs)qvd2.qvd(qvd);

////////////////////////////////////////////////////////////////////////////////////

Final:

Join(qvd2)

LOAD *, IF(UPDATE-CREATEDATE >3, 'N', 'Y') AS INDICATOR

RESIDENT qvd1 ;

DROP TABLE qvd1;

DROP TABLE qvd2;

//The Final: syntax is not working properly.

Anonymous
Not applicable
Author

//Update: The below works.

qvd1:

sql

select * from TableA;

Store qvd1 INTO $vPath_QVDs)qvd1.qvd(qvd);

//////////////////////////////////////////////////////////////////////////

qvd2:

sql

select * from TableB;

Store qvd2 INTO $vPath_QVDs)qvd2.qvd(qvd);

////////////////////////////////////////////////////////////////////////////////////

Final:

Join(qvd1)

LOAD *, IF(UPDATE-CREATEDATE >3, 'N', 'Y') AS INDICATOR

RESIDENT qvd2 ;

//DROP TABLE qvd1;

DROP TABLE qvd2;