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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
tandrisani
Contributor II
Contributor II

Sum if Zero for 3 years

Hello,

 

I have a request to provide a sales report and I'm struggling with the Set Analysis. The request is to show items sold to a specific customer THIS YEAR but NOT in the last three years. In the example below, I would only want to know that Customer A purchased Item 12345 this year for a value of $50.

CustomerPartSales 2016Sales 2017Sales 2018Sales 2019
Customer A1234500050
Customer B12345010050
Customer C123451020300

 

Ideally, I'd like to be able to provide a list of Customers with all the items they purchased this year along with the sales value of those items for this year. 

 

Thank you!

Labels (3)
2 Replies
Stoyan_Terziev
Partner - Creator III
Partner - Creator III

Hello Tandrisani,

 

I'd advise you to do a Cross Table() on the back end so your table looks like this:

CustomerPartYearSales
Customer A1234520160
Customer A1234520170
Customer A1234520180
Customer A12345201950

 

And then on the front-end create a chart with a measure which will be something like:

=If(Sum({<Year={2019}>}Sales)<>0 and Sum({<Year={'*'}-{2019}>}Sales)=0, Sum({<Year={2019}>}Sales), 0)

 

Simple approach now will be:

You can create a chart with the dimensions 

CustomerPart

 

And the measure:

If((Sum([Sales 2016])+Sum([Sales 2017]) + Sum([Sales 2018]))=0, Sum([Sales 2019]), 0)

 

Keep in mind the upper ideas are NOT dynamic, I'm guessing you don't need them to be.

 

I hope this helps!

Kind regards,

S.T.

sunny_talwar

May be this

Dimension

Customer

Expression

Sum({<Customer = P({<Year = {"$(=Max(Year))"}>})-P({<Year = {"<$(=Max(Year))"}>})>} Sales)