Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images | @Reply | Bookmark | Link | Email | Next Unseen |
Top 10 20 50 Sales Rankings
Richard Pitassy 
        
2 years ago
I want to display a text box on our Sales Menu that tells the sales staff if todays sales rank in the top 10, 20 or 50 top sales days of all time.  (A motivation thing.)

I created 3 aggregate queries based on the Sales table using the Return parameter of 10, 20 and 50 respectively.  These queries contain the TransDate date and Sum(SalesAmt) for each date.  My plan was to open each query (on the form open or on current event) and if it contained a TransDate = to [Date] then the text box on my Sales Menu would display the appropriate text ("Top Ten Sales Day or Top 20 Sales Day, etc.)  If today's date was not contained in any of the queries, the text box would be null.

I am stuck on how best to make this work when the Sales Menu opens. I have tried a couple of methods but it's not happening.  A point in the right directed would be much appreciated.

Thanks.
Kevin Yip  @Reply  
     
2 years ago
Make an aggregate query that returns the top N sales in descending order, where N can be 10, 20, or 50 (see Top X).  Save this query as, say, SumSalesQ.  Then you create another query that sorts SumSalesQ in *ascending* order and returns the *top 1* record.  This record will be the Nth rank record.  Compare the Nth ranked sales with your current sales.  If your current sales amount is the same or higher, it is inside the top N.
Richard Pitassy OP  @Reply  
        
2 years ago
Thanks Kevin.  I got it working!
Kevin Yip  @Reply  
     
2 years ago
Just want to add that using a "nested" query eliminates the need to use multiple queries (and clutter up the navigation pane).  E.g.:

     SELECT TOP 1 SumOfSales FROM
     (
          SELECT TOP 20 ... Sum(Sales) AS SumOfSales FROM ... GROUP BY ... ORDER BY Sum(Sales) DESC
     )
     ORDER BY SumOfSales
Richard Pitassy OP  @Reply  
        
2 years ago
Got it.  Thanks!  I'm trying to smarten up on that very topic right now.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
 
What's This?

 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 11/15/2026 3:45:55 AM. PLT: 1s