Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
fzalexanderjohn
Creator
Creator

Sales only for products where a customer received a sample

We often give customers samples of our products. What I want to show is if these samples result in greater sales or not.

So what I need to do is show the sum(sales) only for the product group that the particular customer received a sample from (in the past).

I tried various things but I can't find a way to solve this. I can't find a way to tell Qlik to "keep the connection" between customer and received a sample of this product group.

RevenueCustomerProductProductgroupDateSample
-10KarlA123A01.01.20191
50KarlA122A01.03.20190
-50KarlB110B01.04.20191
150KarlD100D02.04.20190

 

For example in this table Karl should have a revenue based on samples of -10 because he did not receive a sample of Productgroup D. He did receive a sample from Productgroup A and B though, so those products should count.

I provided a Test-App with sample data. The correct value should be 760.

Thanks!

1 Solution

Accepted Solutions
sunny_talwar

Try this

Sum(Aggr(If(Sum(Sample) > 0, Sum(Revenue)), Customer, [Produkt.Productgroup]))

View solution in original post

6 Replies
sunny_talwar

Which rows are you summing to get 760 for Karl?

fzalexanderjohn
Creator
Creator
Author

That is the correct sum for the test app. I have more data in there. In the table above the correct sum should be -10.

sunny_talwar

But how is this calculated in the same app? Which rows are summed to get 760?

fzalexanderjohn
Creator
Creator
Author

RevenueCustomerProductProductgroupDateSampleCalculated
-10KarlA123A01.01.20191X
50KarlA122A01.03.20190X
-50KarlB110B01.04.20191X
150KarlD100D02.04.20190 
100KarlA123A10.10.20190X
400KarlB110B11.10.20190X
300KarlA124A31.12.20190X
-10AlexA123A01.01.20191X
80AlexA122A01.03.20190X
100AlexB110B11.10.20190 
150AlexD100D02.04.20190 
-100AlexA123A10.10.20181X
500PeterA123A01.01.20190 

 

If you sum those rows that are marked with calculated, it should be 760.

sunny_talwar

Try this

Sum(Aggr(If(Sum(Sample) > 0, Sum(Revenue)), Customer, [Produkt.Productgroup]))
fzalexanderjohn
Creator
Creator
Author

I don't understand why this works, but it does. Thanks!