Results 1 to 8 of 8
  1. #1
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486

    Best way to show last month vs this month side by side


    I am trying to create a report like this

    Sales
    Customer Last Month This Month
    Customer 1 500 500
    Customer 2 700 800

    I have all the data but I am getting confused on how I can display it. When i try to create a separate query for each month and then use them both as the source for a new query and use it as a total I end up with too many records, or details and not summary. I am a little confused on the best way to do this. Would it be better to make another table that stores the customer name and amount for each month and then use that for a report?

    Any help is appreciated.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    You can have your 2 queries sum the data by customer for each period of time. In a third query join the customer table to those 2 queries with a join on the customer ID that pulls all records from the customer table. That type of join would make sure you display a customer even if they didn't have a transaction in either of the 2 months.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,451
    perhaps use a crosstab query?
    rowheader customer
    columnheader year/month invoice date
    value - sum invoice value

  4. #4
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    are you talking do the crosstab in excel because I didnt think that they had those in access any more. Crosstab probably would be the best. Thanks to pbaldy, i was able to get the base query working. I was forgetting about adding the customer table and then joining to two queries to that. Howerver, it still doesnt work very well if I add in rider. like below

    Customer| rider| total last month |rider |total this month

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,451
    Crosstabs are alive and well. Think you may be thinking of pivot queries which have now be deprecated

  6. #6
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    Ah, yes, I was definitely thinking of pivot and not crosstab. I will look that up and try it today.

  7. #7
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    Ok, Thanks to Ajax. Yes that is exactly what I was looking for and unfortunately I have mucked about several times with joining queries where that would have really helped. I never use the query wizard and thought that with pivot gone so was crosstab. I actually thought they were basically the same. I actually looked it up to see the difference this morning. It appears that crosstab is basically just a simple fixed pivot. With pivot you can add in new variables and drill down.

    Anyway, I wish they still had pivots in access but the crosstab is great.

    Thanks Ajax

  8. #8
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,123
    If you are interested please have a look at my pivot table builder utility: http://forestbyte.com/ms-access-util...able-designer/

    You can design the pivot in Access and with a click will create an Excel file with the pivot (and the source data so it is totally detached from the db).

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 10-31-2019, 04:32 PM
  2. Replies: 3
    Last Post: 07-11-2019, 09:43 AM
  3. Replies: 6
    Last Post: 09-10-2017, 08:13 PM
  4. Replies: 11
    Last Post: 06-23-2017, 10:25 AM
  5. Replies: 2
    Last Post: 07-25-2016, 01:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums