Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Good day to everyone,
I have a data-set that contains risk data, now I want to filter the data based on the following condition:
for all duplicates of id_acc, execute the following:
Then remove both lines from the data set,
Below is the illustration of what I described above
I have tried to create a flag if the above conditions are satisfied, with the following code:
if((id_acc = previous(id_acc)) and match(mid(ACCOUNT_NUMBER,1,3),'333','999') and (CUSTOMER_KEY = Previous(CUSTOMER_KEY)),1,0) as [delete_flag]
And its not working when I do the count and sum on the front end.
Please assist.
I thank you in advance
You cannot delete a row directly in QlikView.
The only option you have is to load the data into another table using a resident load, with NoConcatenate and a where clause to exclude the rows you wish to remove, and then drop the original table.
Are you getting the delete flag on the correct places after your load the data?
Hi Sunny,
This is the code on the script:
LOAD
Date(MakeDate(Left(info_Date,4),mid(info_Date,5,2),01), 'YYYY/MM/DD') as [Date],
if((id_acc = previous(id_acc)) and match(mid(ACCOUNT_NUMBER,1,3),'333', '999') and (CUSTOMER_KEY = Previous(CUSTOMER_KEY)),1,0) as [delete_flag]
From $(vPortfolioQVDs)\Portfolio_201512.qvd (qvd)
hi can you share some test data?
please share the sample data
-Sathish
I asked an Incorrect question and was corrected by Colin Below
Do you have a order by statement after this? From $(vPortfolioQVDs)\Portfolio_201512.qvd (qvd)?
You cannot specify a sort order on a QVD load directly.
You will need to load the QVD into a temp table first , then do a resident load from the temp table specifying the required sort order.
That's true
Try this
tmpPortfolio:
load
Date(MakeDate(Left(info_Date,4),mid(info_Date,5,2),01), 'YYYY/MM/DD') as [Date],
*
From $(vPortfolioQVDs)\Portfolio_201512.qvd (qvd)
;
Portfolio:
noconcatenate
LOAD
* ,
if((id_acc = previous(id_acc)) and match(mid(ACCOUNT_NUMBER,1,3),'333', '999') and (CUSTOMER_KEY = Previous(CUSTOMER_KEY)),1,0) as [delete_flag]
resident tmpPortfolio
order by id_acc , Date
;
drop table tmpPortfolio ;
issue is due to sorting of the data in Account_Number column..
Edit: Screen shot added for the explanation...