Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
jagannalla
Partner - Specialist III
Partner - Specialist III

Load selected dates from qvd file.

Hi,

I've a Date field in format of timestamp. In one variable i'm storing different number of dates.

For eg:

vDates=07-01-2011,07-02-2011,07-05-2011.

- Now when i loading the qvd file i want to write where condition where the date is equal to all dates of variable.

For Eg;

load * from table.qvd

where match(Date,'$(vDate)');

- But the match function is not working for me. Can anyone help where i'm missing.

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi,

Dates as such are interpreted as text, so each value needs to be single quoted in order to work in a match function. Take the following example

SET vDates = '01/01/2011','03/05/2011'; // Each date is comma separated, single quoted

Data:

LOAD * INLINE [

Date, ID

01/01/2011, A

03/05/2011, B

06/07/2011, C

]

WHERE Match(Date, $(vDates));

The above will only load IDs A and B.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

View solution in original post

8 Replies
Miguel_Angel_Baeyens

Hi,

Dates as such are interpreted as text, so each value needs to be single quoted in order to work in a match function. Take the following example

SET vDates = '01/01/2011','03/05/2011'; // Each date is comma separated, single quoted

Data:

LOAD * INLINE [

Date, ID

01/01/2011, A

03/05/2011, B

06/07/2011, C

]

WHERE Match(Date, $(vDates));

The above will only load IDs A and B.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

Not applicable

I think following code will help you. Instead of placing those dates in variable, place them in an inline table.

Table C will contains all the records from Table A except those which are found in Table B.

IE, Table C = Table A - Table B.

TableA:

LOAD * INLINE [

Customer, Code

A, 1000

B, 2000

C, 3000

D, 4000

E, 5000

F F,6000

F F,6000

];

TableB:

LOAD * INLINE [

Client, Number

B, 2000

D, 4000

G, 7000

];

TableC:

LOAD Customer AS Cust,

           Code AS Cod

RESIDENT TableA WHERE NOT EXISTS(Client, Customer);

Regards

jagannalla
Partner - Specialist III
Partner - Specialist III
Author

Thanks miguel it is working in your code. But it is not working with my qvd file. I'll cross check every thing where i'm missing and let you now when it's works.

Miguel_Angel_Baeyens

Hi,

Note that in the Match() function I'm not quoting the $(vDates) variable, since it's already quoted the values within.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

Not applicable

Hi Miguel,

I am also facing the same problem

I am not able to load the data with where condition by passing variable.

please check the attached files of myne and let me know how they work.

Thanks....

Miguel_Angel_Baeyens

Hi,

First, please, since it's a different question, create a new post with it.

Second, there are two things here, but it all comes to formatting. On your first document, the variable vDates needs to return comma separated, single quoted dates to the variable. So replace in the Variable Overview your vDates variable from using GetFieldSelections to

=Chr(39) & Concat(DISTINCT CaptureDate, Chr(39) & Chr(44) & Chr(39)) & Chr(39)

Now you have the dates as to be used in the Match function.

In the Output document, use the Macth() function as shown above

Where Match(Date(Floor(CaptureDateTime)), $(vDates));

Floor() function is needed because the actual field has not only dates but times as well.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

jagannalla
Partner - Specialist III
Partner - Specialist III
Author

Miguel,

I'm facing with qvd file . I'm attaching my qvw file and qvd can you check once plz...

Miguel_Angel_Baeyens

It's funny how all of you are having the same exact issues with the same exact field names.

Anyway, do as I mentioned above to get the formatting properly using Floor() to get only the date part (not the time part)

Match(Date(Floor(CaptureDateTime)), $(vTotalDates))

And make sure the variable stores the same format of date (for example "MM-DD-YYYY").

Regards.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

Nota Bene: Please read the answers given to other users on the same subject prior to ask the same twice. Hence all of us will save time and keep the threads tidier.