Results 1 to 10 of 10
  1. #1
    BethanyM is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    6

    Totaling Columns

    Hi,

    I am working on a query where I want to see quarterly data. The original tables are set up so that they show sales, transactions, amount, etc. by month.

    What I need to do is group the data by quarter and then sum up that data. I was able to pretty easily create a query that shows each quarter but I have not been able to sum up that data.

    I need the data to be summed up for each quarter for each year so I can then create formulas in a report that shows the difference in performance Q/Q as well as Y/Y.

    I tried using things like DSUM, etc. but have not been able to work.

    Here is the SQL for LY Q3

    SELECT access_dashboard_monthly.qb_merchant_id, access_dashboard_monthly.date_start, access_dashboard_monthly.clicks, access_dashboard_monthly.impressions, access_dashboard_monthly.orders, access_dashboard_monthly.leads, access_dashboard_monthly.sales, access_dashboard_monthly.sales_gross, access_dashboard_monthly.commission, access_dashboard_monthly.sas_fee, access_dashboard_monthly.act_aff, access_dashboard_monthly.total_aff, access_dashboard_monthly.fts, access_dashboard_monthly.aov, Year([date_start]) AS YrNum
    FROM access_dashboard_monthly
    WHERE (((Month([date_start]))=7)) OR (((Month([date_start]))=8)) OR (((Month([date_start]))=9))
    GROUP BY access_dashboard_monthly.qb_merchant_id, access_dashboard_monthly.date_start, access_dashboard_monthly.clicks, access_dashboard_monthly.impressions, access_dashboard_monthly.orders, access_dashboard_monthly.leads, access_dashboard_monthly.sales, access_dashboard_monthly.sales_gross, access_dashboard_monthly.commission, access_dashboard_monthly.sas_fee, access_dashboard_monthly.act_aff, access_dashboard_monthly.total_aff, access_dashboard_monthly.fts, access_dashboard_monthly.aov, Year([date_start])
    HAVING (((access_dashboard_monthly.qb_merchant_id)=[Forms]![***RunReportsForm***]![PickMerchantID]) AND ((Year([date_start]))=2013))


    ORDER BY access_dashboard_monthly.date_start DESC;


    With this formula I easily, can get the data for LYQ3 but once I get that I am not sure how to sum it. Ideally I would like to sum each quarter over multiple years and then create master queries that would then show me all of that data soI can build out formulas to capture the Q/Q and Y/Y performance.

    Thanks in advance for any help you may be able to provide.

  2. #2
    dipique is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    31
    If you're doing this in access, the "Report" functionality may be ideal for you. If not, try posting your database so we can better visualize the issue.

  3. #3
    BethanyM is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    6
    Hi,

    How would I go about posting my database? I know I can sum an individual quarter in the Access report. But the issue is that that only covers let's say the present quarter and in reality I need a query that lists the data broken down individually by quarter. So for instance This Year Quarter 3 would just be (July-September) of this year summed. But I also need that query to show me what This Year Quarter 2 is as well as Last Year Quarter 3. My problem is I can get any one of the three to work properly in a query but not all 3.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,643
    Construct fields in query that can be used to organize the records by query/year, month/year:

    SELECT *, Format([date field],"yyyyq") AS YrQtr, Format([date field]), "yyyymm") As YrMo FROM tablename;

    or

    SELECT *, Year([date field]), DatePart("q",[date field]) AS Qtr, Month([date field]) As Mon FROM tablename;

    Now use that query as source for subsequent queries.

    Might find this of interest: http://allenbrowne.com/subquery-01.html#YTD

    To provide db, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    BethanyM is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    6
    I have included a YrNum, MoNum, QtrNum to be able to restrict data. Ex. Year([date_start]) AS YrNum

    I use a where statement to restrict the quarter currently. My issue is that I can clearly see which values belong to which quarter, I am just not sure how I can total them to be able to display in the report.

    My db even with removing sensitive data is over 2MB, so I cannot attach.


  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,643
    Zip is over 2MB? Can upload to a fileshare site such as Box.com and post link to the file.

    Use aggregate (GROUP BY) totals query.

    Or as dipique suggested, build a report and use its Grouping & Sorting features with aggregate calcs in footers. This will allow display of detail records as well as summary calcs. If you want a prior year month or quarter next to current month or query, review the Allen Browne tutorial I referenced.

    Maybe even report/subreport will be needed to get desired output.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    BethanyM is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    6
    Sorry about the delay but here is my database. What I am trying to do is have the report that is the subreport populate this qtr's data, last qtr's data, and q/q change right now. In order for this to work, I have created a query where I put in time variables QTR, YRNum, etc. and I have added in sorting and grouping on the report. My issue is that it shows me the data for this year's qtr and last year's qtr but it is not in the same chart.Test4Forum.zip

    I've also considered using DSUM or DLookup to populate the other columns but I am receiving errors. Here is what I input into the field: =DSum([clicks],[QryQ3DataAll2],[YrQtr]=2013-3)

    I also added in the YrQtr that was suggested just now and there isn't a real difference (i.e. the first column of my table works but not the others)

  8. #8
    BethanyM is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    6
    I got the Dsum to work so I can now populate the rest of the table. The only issue now is that I only want it to show me one table but since it sees that there are numerous records it is trying to display them. Any idea on how to restrict it from creating additional tables?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,643
    Your table is a link (MySQL, Oracle?) so I cannot test. You have to provide db with imported data.

    I don't understand your last post. I thought the issue was building a query. When did populating a table enter the picture? What is 'creating additional tables'?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    BethanyM is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    6
    I solved it. I created a query then created another query based off of that where I used DSum to calculate the quarterly totals.

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

Similar Threads

  1. Sub Totaling in a report
    By keiath in forum Reports
    Replies: 11
    Last Post: 04-04-2014, 06:28 AM
  2. Sub totaling in a query or report
    By n2mee in forum Queries
    Replies: 8
    Last Post: 11-16-2013, 03:55 PM
  3. Totaling on a report
    By eskybel in forum Access
    Replies: 9
    Last Post: 04-02-2013, 01:11 PM
  4. Running totaling with a query
    By tttccc in forum Queries
    Replies: 1
    Last Post: 03-28-2012, 09:37 AM
  5. Totaling a value in group footer...
    By hodgy20 in forum Reports
    Replies: 0
    Last Post: 11-14-2008, 08:28 AM

Tags for this Thread

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