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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Resident Load with a where Clause - Possible?

Hi all,

I'm here again to ask silly questions!

I am trying to load data into a QVW using 2 select statements, the second select statement will limit what it loads based on the data in the first.

So basically i want code like this:

(imagine ColA, Col1 and Col2 are dates, as dates are what i want in this example)

SQL SELECT

ColA

ColB

ColC

FROM TableA

SQL SELECT

Col1

Col2

Col3

FROM Table1

WHERE ColA BETWEEN Col1 AND Col2

Now, i didnt try the code above, but in my head that code wont work, as i cant reference the table that isn't created yet (if that makes sense) so, i thought of a resident load.

So, in my head i would use this code:

TblA:

SQL SELECT

ColA

ColB

ColC

FROM TableA

Tbl1:

SQL SELECT

Col1

Col2

Col3

FROM Table1

Tble1:

LOAD * RESIDENT Tbl1

WHERE WHERE ColA BETWEEN Col1 AND Col2

But, when i try this, the code is underlined with errors, and now im a little stuck as to whether or not WHERE clauses can be used this way in resident loads. If they are, how would i go about using it? If not What is the best way to achieve my goal.

Hopfully this makes sense.

Kind regards,

Chris

7 Replies
flipside
Partner - Specialist II
Partner - Specialist II

Hi Chris,

Your logic doesn't really work.  You want to filter TableA load on ColA where its value is between Col1 and Col2 in another table, however there will be multiple rows (I assume) for ColA to match against so is there some other link between the tables? Perhaps an example might help.

flipside

Not applicable
Author

He Chris,

If you want use ColA from table A in Table 1, you have to join the tables first.

After you have joined the tables you should be able to use your where statement.

Hope this helps.

gr.

Frank

swuehl
MVP
MVP

I don't think this will work.

First you need to clarify:

I assume ColA may contain several records / values, let's say 1, 2, 5 ,10

Now, when reading the first record in your Tble1 Load, let's assume Col1 is 3 and Col2 8.

So how should QV proceed? There are some values for ColA that are inbetween the interval, some are not.

The Where clause is ambiguous.

(Besides, you can't reference ColA like that, even with only one record for that field).

Not applicable
Author

post a sample qvw file

Not applicable
Author

Hi,

Thank for your replies, i realise that it wouldnt work like that, hense why i asked. I was hoping that may at least describe what i was trying to achieve.

In the examples given ColA will be the date a test was done. Col1 is Admission Date  and Col2 is Discharge Date.

The problem i have is that the 2 systems i am using do not have a common link between them. All i can do is link on patient and ward. however as a patient can be on a ward more than once, i was trying to only load data where there was a test between admission and discharge.

however, the more i think on this, the the more it seems liek this wont work, and as said above, i will probably have to write a SQL statement with the joins in, rather than allowing Qlikview to join itself.

Sorry for the time wasting, but that will be the way i progress, it hurts my head less.

flipside
Partner - Specialist II
Partner - Specialist II

I think Qlikview might be easier in this scenario, you can add the PatientID key into the intervalmatch, then join the ward id back in based on patientID, WardStart and End dates ...

Inspections:

Load * inline [

PatientID,    Inspection

100,    01/11/2012 12:00:00

101,    06/11/2012 13:00:00

101,    13/12/2012 09:00:00

102,    23/11/2012 11:00:00

102,    12/12/2012 14:00:00

100,    30/10/2012 16:00:00];

WardSpells:

Load * inline [

PatientID,    WardStart,    WardEnd,    Ward

101,    05/11/2012 08:00:00,    08/11/2012 11:00:00,    Ward1

101,    01/12/2012 09:00:00,    13/12/2012 02:00:00,    Ward2

101,    13/12/2012 02:01:00,    14/12/2012 12:00:00,    Ward1

102,    20/11/2012 13:00:00,    22/11/2012 15:00:00,    Ward6

102,    24/11/2012 11:00:00,    13/12/2012 20:00:00,    Ward3

];

left join (Inspections)

intervalmatch(Inspection,PatientID)

LOAD WardStart,WardEnd,PatientID RESIDENT WardSpells;

left join

LOAD * resident WardSpells;

Drop Table WardSpells;

I would think this is easier than SQL.

flipside

Not applicable
Author

agree with what he said.....Instead of writing SQL try this one..it should work....