Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to match dates between tables and sum if <=

Hey all,
I'm pretty new to QlikView so sorry if this is basic or worded oddly, I'm still getting used to the vernacular as well. My problem is I have 3 SQL tables. One that contains items, one that contains transactions done against each item, and one that contains work done to each item. What I'm trying to do is find the last time work was done on each item and then sum all transactions that were done on the item prior to this date. So for example,
Item table
Items
Item 1
Item 2
Item 3
Transaction table
ItemQTYDate
Item 151/3/13
Item 121/3/13

Item 2

71/1/13
Item 331/1/13
Item 341/2/13
Item 311/4/13

Work table

ItemDate
Item 11/3/13
Item 21/2/13
Item 31/2/13
Item 31/3/13

Result table

ItemLast Work DateQTY at Date
Item 11/3/137
Item 21/2/137
Item 31/3/137

I am able to do all of this partially, but only if a single item is selected. Otherwise is shows 0 for all in 'QTY at Date.' I'm doing this by,

(SUM(IF(Transdate<=DATE(FIRSTSORTEDVALUE(workdate,-workdate))),transqty))

What I think is happening is that it is trying to compare the whole array of workdates, for all assets, to the transaction dates and when I select a single asset this solves the problem and it starts working. If you have any ideas of how to handle something like this better or what my problem might be I would appreciate it. Thanks. If you need any more information just let me know.

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

This showed me how to accomplish what I was wanting to do.

http://community.qlik.com/thread/57878

View solution in original post

4 Replies
Gysbert_Wassenaar

See attached example.


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

Thanks for the quick response. I think I might have simplified my question a bit too much. My problem now is that I need to look at an addition table to determine if the date in the Work Table is one of the dates that I'm interested in. I reworked your example a bit if you wouldn't mind checking it out. I think it will explain it better than I can.

Thanks again

Anonymous
Not applicable
Author

This is probably a little more accurate for what I'm doing currenlty actually.

The right() is only in there because in the real version the template is something like XXX_XXX_A, etc.

Anonymous
Not applicable
Author

This showed me how to accomplish what I was wanting to do.

http://community.qlik.com/thread/57878