Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sales and Returns pivot table

First post...hello all!

I'm working with two tables, sales and returns.

Sales table has sale date, sale tran #, and sold qty.

Return table has return date, sale tran #, sale date and return qty.

i need to create a pivot table that will show the sales (current month for example), and display if there was a return, the return date and qty.

Right now, i see every instance of a return, not just the one associated to that sale.

sale datetrans #return datesale tran #sale qtyreturn qty
total11
item a6/1/201019004/1/2008162511
5/1/200917521
6/3/201019001


Can set analysis be used to solve this problem?

Thank you,

1 Solution

Accepted Solutions
johnw
Champion III
Champion III


scarvajal wrote:
i don't control the data model, what if my IT counterpart is not able to link by sales tran #?<div></div>


Well, the right thing to do is probably to link the fields in the data model. Either "trans #" should be renamed to "sale tran #" or vice versa during the load script.

If that isn't practical for some reason, you can link the two fields up in the expression(s). For instance:

sum(if("trans #"="sale tran #","sale qty"))

The problem is that performance will be horrible if your data model is large. It'll be fine if its a fairly small set of data, though, so it might be good enough.

Edit: On the other hand, if these fields aren't linked in the data model, you'll probably have an endless number of headaches, of which this is merely the first. Coming up with an ugly workaround for every single problem is really not the way to handle it. It's like saying you want to drive across the country, but want to do it without tires on the car. Technically doable, but ill-advised. You may not be the mechanic, but someone needs to put tires on the car.

View solution in original post

4 Replies
pover
Partner - Master
Partner - Master

What's your data model like? For this particular report you should link the sales and returns table by using the "sales tran #'.

Then you don't have to worry about doing set analysis or a sum(if).

Regards.

Not applicable
Author

i don't control the data model, what if my IT counterpart is not able to link by sales tran #?

johnw
Champion III
Champion III


scarvajal wrote:
i don't control the data model, what if my IT counterpart is not able to link by sales tran #?<div></div>


Well, the right thing to do is probably to link the fields in the data model. Either "trans #" should be renamed to "sale tran #" or vice versa during the load script.

If that isn't practical for some reason, you can link the two fields up in the expression(s). For instance:

sum(if("trans #"="sale tran #","sale qty"))

The problem is that performance will be horrible if your data model is large. It'll be fine if its a fairly small set of data, though, so it might be good enough.

Edit: On the other hand, if these fields aren't linked in the data model, you'll probably have an endless number of headaches, of which this is merely the first. Coming up with an ugly workaround for every single problem is really not the way to handle it. It's like saying you want to drive across the country, but want to do it without tires on the car. Technically doable, but ill-advised. You may not be the mechanic, but someone needs to put tires on the car.

Not applicable
Author

great advice John, thank so much Smile