Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have a data like below:
Date | Name |
17-Aug-2020 | Phillip Summers |
18-Aug-2020 | Quamar Tran |
19-Aug-2020 | Daquan Gray |
20-Aug-2020 | Nasim Rodriguez |
21-Aug-2020 | Ryder Bryant |
22-Aug-2020 | Galvin Hays |
23-Aug-2020 | Austin Navarro |
24-Aug-2020 | Dieter Padilla |
25-Aug-2020 | Nissim Vargas |
26-Aug-2020 | Calvin Rosales |
27-Aug-2020 | Lance Hensley |
28-Aug-2020 | Ethan Odonnell |
29-Aug-2020 | Oscar Harmon |
30-Aug-2020 | Ira Moore |
31-Aug-2020 | James Mitchell |
Now I want to load data for each date and store it in each qvd and I have written the below script:
TMP_TABLE:
LOAD
DATE(Date,'DD-MMM-YYYY') AS Date,
Name
FROM
[C:\Users\smandal\Downloads\Test.xls]
(biff, embedded labels, table is Worksheet$);
FOR i =0 TO (NOOFROWS('TMP_TABLE')-1)
LET v_data = PEEK('Date',i,'TMP_TABLE');
NOCONCATENATE
TABLE:
LOAD * RESIDENT TMP_TABLE
WHERE Date = '$(v_data)';
STORE TABLE INTO C:\Users\smandal\Downloads\$(v_data)_TEST.QVD(QVD);
NEXT i
But it is not working. The code is generating qvd from 17-Aug-2020 to 31-Aug-2020 but data in the qvd is same for all.
Please help.
You code looks fine. You should add a "drop table" at the end of each iteration of the for-loop. Just before calling "next".
I have tried to rebuild your app and traced v_data with the following command. It was empty.
Trace 'v_data: $(v_data)'
Make sure Date in your source file is an actual valid date field. It worked when I replaced Date() with Date#().
Here's the full code:
SRC:
LOAD * INLINE [
Date, Name
17-Aug-2020, Phillip Summers
18-Aug-2020, Quamar Tran
19-Aug-2020, Daquan Gray
20-Aug-2020, Nasim Rodriguez
21-Aug-2020, Ryder Bryant
22-Aug-2020, Galvin Hays
23-Aug-2020, Austin Navarro
24-Aug-2020, Dieter Padilla
25-Aug-2020, Nissim Vargas
26-Aug-2020, Calvin Rosales
27-Aug-2020, Lance Hensley
28-Aug-2020, Ethan Odonnell
29-Aug-2020, Oscar Harmon
30-Aug-2020, Ira Moore
31-Aug-2020, James Mitchell
];
TMP_TABLE:
NoConcatenate LOAD DISTINCT
DATE#(Date,'DD-MMM-YYYY') AS Date,
Name
RESIDENT SRC;
drop table SRC;
FOR i = 0 TO NOOFROWS('TMP_TABLE')-1
LET v_data = PEEK('Date',i,'TMP_TABLE');
trace 'v_data: $(v_data)';
trace $(v_data);
NOCONCATENATE
TABLE:
LOAD * RESIDENT TMP_TABLE
WHERE Date = '$(v_data)';
STORE TABLE INTO lib://DEV/$(v_data)_TEST.QVD(QVD);
drop TABLE;
NEXT i
is it same as below?
https://community.qlik.com/t5/New-to-QlikView/Loop-issue/m-p/1736377#M392163