2 Replies Latest reply on Jun 16, 2017 4:47 AM by Tushar More

    Evenly distributed groups

    Signar Jakobsen



      Let me start by explaining the data structure and the goal.


      I work in lead generation, and I have a list of customers that are able to handle varying amounts of leads per month -- anywhere from 1 to -- but I will be ignoring the infinites for this calculation. We sell leads to a maximum of 4 customers, giving us a one-to-many relationship.



      The question I'm trying to answer is this: How many leads can we sell to 4, 3, 2 and 1 customer(s) respectively. This is to avoid "overselling", since selling to only 2 customers is usually unprofitable.



      I've attached a mock up illustration of what I'm attempting to achieve below.



      Imagine that the bars represent individual customers, and the height of the bars represent their capacity in number of leads.



      In this example we get the answer 75 leads to 4 customers, which equates to (75*4) = 300 deliveries. An additional 5 can be sold to 3 customers, and the last 20 can only be sold to 1.



      I'm looking to solve this either in Tableau, if possible, or through SQL operations.

      Before.pngAfter.png*not to scale