Skip to main content

Overview

The Sales Management App includes an intelligent recommendation algorithm that provides personalized sales targets to help salespersons improve their performance. This guide explains how the algorithm works and how to use its recommendations effectively.

Accessing Recommendations

1

Navigate to Leaderboard

Open the Leaderboard from the salesperson sidebar menu.
2

View Your Ranking

Wait for the leaderboard to load and display all team members ranked by Performance Index.
3

Get Your Recommendation

Click the floating action button (FAB) on the leaderboard screen to see your personalized target.
The recommendation algorithm is only available to salespersons and appears on the leaderboard screen (source:~/workspace/source/app/src/main/java/project/avishkar/salesmanagement/Leaderboard/LeaderBoardSalesperson.java:66).

How the Algorithm Works

The recommendation system uses a multi-step calculation process to determine your optimal sales target.

Step 1: Calculate Performance Index

For each salesperson, the system calculates a Performance Index (PI):
Performance Index = Total Profit Generated / Days Since Registration
Components:
  • Total Profit Generated: Sum of (Items Sold × Profit Per Item) across all products
  • Days Since Registration: Time elapsed since the salesperson joined the team
The Performance Index normalizes profit over time, ensuring fair comparison between veteran salespersons and new team members.

Step 2: Data Collection

The algorithm collects data for all salespersons under the same manager:
1

Retrieve Salesperson List

System queries all salespersons linked to the current manager.
2

Calculate Individual Profits

For each salesperson, the algorithm iterates through their inventory to calculate:
totalProfit = Σ(inventoryItem.sold × inventoryItem.profit)
3

Fetch Registration Timestamps

System retrieves signup timestamps from the LeaderBoard database node (source:~/workspace/source/app/src/main/java/project/avishkar/salesmanagement/Leaderboard/LeaderBoardSalesperson.java:193).
4

Compute Time Differences

daysSinceSignup = ((currentTime - signupTime) / 86400) + 1
Time is calculated in seconds and divided by 86400 (seconds per day). Adding 1 prevents division by zero for new members.
5

Calculate Performance Indices

For each salesperson:
performanceIndex = totalProfit / daysSinceSignup

Step 3: Identify Top Performer

The algorithm identifies the highest Performance Index in the team:
PI_topper = max(performanceIndex[])
This represents the best-performing salesperson’s normalized profit rate. For the current salesperson, the algorithm calculates their target profit:
Target Profit = (PI_current + (PI_topper - PI_current)) × 1.10
Breaking down the formula:
  1. PI_current: Your current Performance Index
  2. PI_topper: The top performer’s Performance Index
  3. (PI_topper - PI_current): The gap between you and the top performer
  4. PI_current + gap: Your PI if you matched the top performer
  5. × 1.10: Adds 10% growth factor for continuous improvement

Conservative Growth

The algorithm doesn’t expect you to jump directly to the top performer’s level.

Realistic Targets

By closing the gap incrementally, targets remain achievable and motivating.

Continuous Improvement

The 10% growth factor ensures even top performers have stretch goals.

Fair Competition

All calculations use time-normalized data for equitable comparisons.

Example Calculation

Let’s walk through a real-world example:

Scenario Setup

Your Performance:
  • Total Profit Generated: $5,000
  • Days Since Registration: 50 days
  • Your PI: 5,000/50=5,000 / 50 = 100 per day
Top Performer:
  • Total Profit Generated: $8,000
  • Days Since Registration: 40 days
  • Their PI: 8,000/40=8,000 / 40 = 200 per day

Target Calculation

1

Calculate Gap

Gap = PI_topper - PI_current
Gap = $200 - $100 = $100 per day
2

Add Gap to Your PI

Matched Performance = $100 + $100 = $200 per day
3

Apply Growth Factor

Target = $200 × 1.10 = $220 per day
4

Your Recommended Target

Target Profit: $220 per dayThis means you should aim to generate $220 in daily profit to improve your ranking and performance.

Interpreting Your Target

With a target of $220/day:
  • You need to increase daily performance by 120% (100100 → 220)
  • This closes the gap with the top performer and adds 10% growth
  • If you achieve this consistently, you’ll become the new top performer
  • The algorithm will then give you a new target based on your improved PI

Implementation Details

The algorithm is implemented in the LeaderBoardSalesperson class (source:~/workspace/source/app/src/main/java/project/avishkar/salesmanagement/Leaderboard/LeaderBoardSalesperson.java:66-135).

Key Code Flow

1

User Triggers Recommendation

Salesperson clicks the FAB button on the leaderboard screen.
2

Retrieve Current User Data

DatabaseReference.getReference("Salesperson")
  .addListenerForSingleValueEvent()
System fetches the current salesperson’s data using session ID.
3

Access Performance Index Array

The performanceIndex ArrayList contains PI values for all team members in the same order as the leaderboard.
4

Find Maximum PI

Double PiTopper = Collections.max(arrayList)
Identifies the highest-performing salesperson’s PI.
5

Locate Current User's Position

for(i=0; i<SalespersonList.size(); i++) {
  if(SalespersonList.get(i).getName().equals(currName))
    break;
}
Finds the current user’s index in the leaderboard.
6

Calculate Target

Double PiCurr = Double.parseDouble(performanceIndex.get(i));
Double targetProfit = (PiCurr + (PiTopper - PiCurr)) * 1.10;
7

Display Recommendation

Shows the target in a custom dialog with a circular progress animation.

Benefits of the Algorithm

Personalized Goals

Each salesperson receives a target based on their specific performance level and the team context.

Motivation Through Competition

Seeing the gap to the top performer motivates improvement while keeping goals realistic.

Fair Comparisons

Time normalization ensures new members aren’t disadvantaged against veterans.

Continuous Improvement

The 10% growth factor ensures that achieving your target pushes you to new heights.

Team Benchmarking

Targets are based on real team performance, not arbitrary corporate goals.

Dynamic Updates

As team performance changes, so do the recommendations, keeping them relevant.

Using Recommendations Effectively

For Salespersons

1

Check Your Target Regularly

Review your recommended target at least weekly to stay focused on improvement.
2

Break Down the Goal

If your target is $220/day:
  • Calculate how many units you need to sell
  • Identify high-profit items to prioritize
  • Plan your daily sales activities
3

Track Progress

Use the Statistics view to monitor your daily profit and compare it against your target.
4

Adjust Strategy

If you’re consistently missing your target:
  • Focus on higher-profit items
  • Increase sales volume
  • Learn from top performers

For Managers

While managers don’t see individual recommendations, understanding the algorithm helps you:

Coach Effectively

Explain how the targets work to help salespersons understand their goals.

Set Inventory Strategy

Stock higher-profit items to help salespersons reach their targets.

Identify Struggling Members

If someone consistently misses their target, provide additional support.

Celebrate Top Performers

Recognize that the top performer’s success influences the entire team’s targets.

Algorithm Limitations

While powerful, the algorithm has some considerations to keep in mind.

Edge Cases

  1. New Team Members: Salespersons registered for only 1-2 days may see volatile targets as their PI stabilizes.
  2. Small Teams: In teams with only 2-3 salespersons, one strong performer can create very high targets for others.
  3. Product Mix Changes: If a manager adds high-profit items, historical PIs may not reflect new opportunities.
  4. Seasonal Variations: The algorithm doesn’t account for seasonal sales fluctuations.

Best Practices to Overcome Limitations

1

Give Time to Stabilize

Don’t stress over targets in your first week. Focus on learning products and building a baseline.
2

Communicate with Your Manager

If targets seem unrealistic, discuss with your manager. They can provide context about team dynamics.
3

Use as a Guide, Not a Rule

The target is a recommendation, not a requirement. Use it to motivate improvement at your own pace.
4

Track Trends Over Goals

Focus on whether your PI is trending upward over weeks, not whether you hit the exact target daily.

Future Enhancements

Potential improvements to the algorithm could include:
  • Seasonal Adjustments: Factor in historical seasonal trends
  • Product Weighting: Consider difficulty of selling different products
  • Confidence Intervals: Provide a target range instead of a single number
  • Time-Based Targets: Separate daily, weekly, and monthly recommendations
  • Custom Growth Factors: Managers could adjust the 10% growth rate per team member

Conclusion

The recommendation algorithm provides a data-driven approach to setting sales targets. By considering both individual performance and team context, it creates personalized, achievable goals that drive continuous improvement.
The most successful salespersons use the recommendation as one tool among many. Combine it with manager feedback, personal experience, and market conditions for optimal results.

Build docs developers (and LLMs) love