Pull YTD and MTD from Table

Sully38

Board Regular
Joined
Mar 9, 2004
Messages
167
I have a table that contains currency data in monthly rows. I need to generate a query that will select just the current Month and sum it as MTD and also sum the previous months up to the current month as YTD.
Example Feb MTD would be Feb and Feb YTD would be Jan + Jeb. Is this possible within a query? or is this something that needs some VBA Coding. :cool:
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
it's vba

Sully,

What you should do is start with a baseline query that groups as you need the items to group...and then plug that custom function into your query and have it use the return value from the function.

This is pretty vague but might point you in the right direction.

Alternatively - and a little clumsier - create a query and extract a portion of the date field into a 'new' field. Use that field inside a Crosstab query to identify the totals you want and use where needed.

Mike
 
Upvote 0

Forum statistics

Threads
1,221,854
Messages
6,162,450
Members
451,765
Latest member
craigvan888

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top