MS Excel Formulas to Access reports

So I have been keeping track of lots of stuff in an Excel sheet and decided to convert it / learn MS access. i have put in 1 element that i want to track, most of the others will be similar to this one. I have inputted all the data into a table (see below) the categories are all lookups to other tables. For reference i have put in what the excel doc and the "report" that that I am looking to replicate, I basically want to be able to break down the electric costs for each month and compare year over year, and averages. i saw some stuff relating to sumif, but i dont know really how to start.

I am familiar with SQL, should i be doing this in a SQL query, and sub queries, or a report?

ImageImage

Image

I would create a crosstab query with a Row Heading of Month([Expense Date]). The Column Heading would be the Year([Expense Date]) and the Value would be Sum([Cost Field]). You should be able to get the average and total in a group or report header section. I'm not sure how you derive your Min, Max, and Overall Average but these could be a subreport or created in a separate query. Your column heading will vary next year and every year after which could cause an issue or editing the design. There are ways around this using a relative year which is discussed at https://www.tek-tips.com/faqs.cfm?fid=5466

Duane Hookom
Minnesota

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Before you start thinking about queries and reports, you need to get your database design right. For example, you do not store inferable data in a database table. You therefore do not store the month and year if you have already stored the date. I also have my doubts about Category class, Top level category and Minor category. If the data is always stored down to the Minor category level, the other two are redundant. It should be clear in other tables to which Top level category and Category class a Minor category belongs. In that case only Minor category should be stored here.

Groeten,

Peter

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Thank you very much, ill give this a try.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

The idea was to have a major category, (Household, Utilities, upkeep, ...) i have more but for purposes these 3 major ones;

Then Top Level would be:

-Household (food, clothes, )

-Utilities (gas, electric, ...)

-Upkeep (Item, service, ...) as in upkeep to the house

Then only some would have a minor category

Upkeep (house, bedroom, bathroom, patio, ...)

All would have a store date and a cost

The idea was to slice it as big (major category) or as small (upkeep by room) without having to constantly go in and change data / filter in excel like I was doing before. also my wife said "oh that should be its own category", so now if it is set up correctly it is as simple as just adjusting or making a new category or sub category and changing a filter to show the data. I can do a cross section over time of how much we pay year over year like food costs, electric (or quickly switch to all utilities) year over year or from the same month in previous years. that i can do now but it is not as dynamic.

There is just 1 expense table and the Major category, Top level category, Minor category, Purchased from are separate tables that are linked with the index from those tables.

Does that make sense?

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

ok nice this works for sum, I did need to use the month () function but that was easy

TRANSFORM Sum(Expenses.[Expense Cost]) AS [SumOfExpense Cost]

SELECT month(Expenses.[Expense Month]), Sum(Expenses.[Expense Cost]) AS [Total Of Expense Cost]

FROM Expenses

WHERE [category class] = 2

GROUP BY month(Expenses.[Expense Month])

PIVOT Format([Expense Year],"yyyy");

I still have to figure out how to rename the 1 to January and I think I can do a union to get the yearly totals,

thanks for the help

Image

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

You can use the MonthName() function. You should be able to year totals in the report header.

Duane Hookom
Minnesota

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

So have been able to get the query working well but i hard coded the utilities number in the query.

TRANSFORM sum(Expenses.[Expense Cost]) AS [Sum]

SELECT Expenses.[Category Class], Month(Expenses.[Expense Month]) & " - " & MonthName(Month(Expenses.[Expense Month])) AS [Month], Avg(Expenses.[Expense Cost]) AS [Monthly Average]

FROM Expenses

WHERE (((Expenses.[Category Class])=2))

GROUP BY Month(Expenses.[Expense Month]), Expenses.[Category Class]

PIVOT Format([Expense Year],"yyyy");

I also figured out what dhookom was talking about with 2023 ( i added a test item in 2023 so it would not fail) i saw a post here https://learn.microsoft.com/en-us/previous-versions/office/developer/office-2007/bb243764(v=office.12)

but I want to have a drop down in the report, to select the category class and if i want drill down further. does anyone have any pointers as to a post that may show how to do that?

Thanks in advance

Image

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Crosstab queries require you to specify the data type of all parameters. Check the query properties for “parameters”.

Image

Duane Hookom
Minnesota

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 23, 2025 Views 160 Applies to: