Help with considering all products in dataset even with zero sales


I have been using large dataset for a while now and the important consideration is to keep in mind the products sold for the last 10 years for all of our needs. With the help of this community support, I was able to complete some of the important tasks using this data. I am realizing, however, that there are several products that we don't sell anymore but because we did sell them within last 10 years at some time, we need to incorporate those as well for selected time as long as they fall under last 10 years selling time period.

Here is the link that helped me getting last 10 years worth sales for any given Product Type. Sample example was for 3 years only for concept purpose. What's happening here is that all the calculations are getting performed for Sales that are happening and we are not able to capture some of the products that were sold few years back within last 10 years.

Any support here will be highly appreciated.



The post you link to does not seems to have the data you are talking about here. I do not see any products with individual sales per year, only "Type" for which there is data for both A and B until 2021.

Please create a reprex with the data that creates the issue. A reprex consists of the minimal code and data needed to recreate the issue/question you're having. You can find instructions how to build and share one here:

Good luck,

is this a different issue from this one ?
Help with Adding all Dates for all Products - General - RStudio Community

1 Like

Yes, I apologize @pieterjanvc , in this case it is "Type" which I am treating as Product.
The data in the link is correct.

Yes @nirgrahamuk ! Problem is same, but scenarios are different.
Here, I would like to extend this existing query where somehow we can consider all "Types" as long as they are sold in last 10 years (3 years for this example) for each date (Year and Month).

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.