ks-man
ks-man

Reputation: 167

KDB - Filter List Column Based on Another Column

I'm struggling with eliminating data from my query. I have attached a picture with my data results (data itself is too large and has customer info so I can't include). I have two tables that I'm joining by SKU to show when we enter a SKU into the system and when we sell it. We reuse SKUs based on vendors which isn't the best practice but is currently a necessity. What I'd like to do is eliminate the InvoiceDates where InvoiceDate < TransferDate. So in the InvoiceDate column it would only show the highlighted yellow dates for the first few rows.

Please let me know if you have any questions and thanks for the help!

Data Result

Upvotes: 0

Views: 2015

Answers (2)

Rahul
Rahul

Reputation: 3969

This would work:

 q) update InvoiceDate:{x where x >= y}'[InvoiceDate;TransferDate] from tbl

Explanation:

Above query uses 'each-both(') function to iterate over InvoiceDate and TransferDate values pair wise(indirectly row wise), pass each pair to lambda function as 'x' and 'y' and then select 'x'(InvoiceDate) which are >= 'y'(TransferDate)

Upvotes: 1

user2242865
user2242865

Reputation: 567

You question is cut off, but I'm guessing you want to filter on whether a particular date is in your invoiceDate lists. You can do this as follows:

q)select from tbl where in[2019.01.01;] each invoiceDate

If this isn't what you are looking for, please clarify above with an example

Upvotes: 0

Related Questions