You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Formula for Month and Year-to-Date Comparisons

I have 2 tables where I enter expense. For the most part, it’s a single entry each month. But, there are exception (May 2022).


In the 2023 table, I compare monthly expense against the same period from the previous year, as well as Year to Date.


Currently, I do the comparisons manually in columns E and H in the 2023 table.  For example, column H (Year to Date) for August I changed my formula by adding 2023 C9 and 2022 C10. Unless I have a second entry later his month, next month I will adjust add 2023 C10 and 2022 C11.


Is there a formula that would automatic this process so I only need to make an date and amount entry in the current year’s table?


As always thank you.


MacBook Pro 15″, macOS 11.7

Posted on Aug 25, 2023 7:46 AM

Reply
Question marked as Top-ranking reply

Posted on Aug 25, 2023 9:04 AM

You can use SUMIF to sum the values from 2022 for the same month as in 2023. While not absolutely necessary, it would be a much simpler formula if you used column B in both tables to extract the month from each date. You can set the text color to white or the opacity to 0 so you don't see the numbers. There is one other problem to solve, though. If 2023 has two entries for a particular month, you don't want to calculate that month twice.


In both tables, the column B formula is

=IF(A2≠"",MONTH(A2),"")

fill down to complete the columns


In 2023 column E,

E2 =IF(AND(B1≠B2,A2≠""),SUMIF(B,B2,C)−SUMIF(2022::B,B2,2022::C),"")

fill down to complete the column


The check for A2≠"" is so you only do the calculation/formula if there is a date in column A

The check for B1≠B2 is so you don't calculate the same month twice. That would throw off your year-to-date calculation. It requires the table to be in chronological order, you can't have an entry for May then June then May again.


Similar questions

3 replies
Question marked as Top-ranking reply

Aug 25, 2023 9:04 AM in response to Marg0040

You can use SUMIF to sum the values from 2022 for the same month as in 2023. While not absolutely necessary, it would be a much simpler formula if you used column B in both tables to extract the month from each date. You can set the text color to white or the opacity to 0 so you don't see the numbers. There is one other problem to solve, though. If 2023 has two entries for a particular month, you don't want to calculate that month twice.


In both tables, the column B formula is

=IF(A2≠"",MONTH(A2),"")

fill down to complete the columns


In 2023 column E,

E2 =IF(AND(B1≠B2,A2≠""),SUMIF(B,B2,C)−SUMIF(2022::B,B2,2022::C),"")

fill down to complete the column


The check for A2≠"" is so you only do the calculation/formula if there is a date in column A

The check for B1≠B2 is so you don't calculate the same month twice. That would throw off your year-to-date calculation. It requires the table to be in chronological order, you can't have an entry for May then June then May again.


Aug 25, 2023 9:30 AM in response to Badunit

One other thing: If you add a row in the middle of the 2023 table, you will have to adjust the column E formula for the row below it so the B2≠B1 check points to the new row. Otherwise it will be pointing to 2 rows above. If this is a problem or you will be sorting the table or anything like that, we can use OFFSET to reference the correct row and that problem will be eliminated. B2≠OFFSET(B2,-1,0)

Aug 26, 2023 8:14 AM in response to Badunit

Badunit,


Thank you for your help. It's a perfect solution for my month-to-month comparison. But, it's well above my limited experience level. I spent most of yesterday understanding how your formula works. I believe I got it...


I tried to adapt the formula to work in column H (2023) for the Year-to-Year comparison. I cannot figure out how to do the cumulative SUMIF from January through the current month.


I'm going to leave my post open for a few days hoping for additional help with a solution for the Year-to-Year comparison.


Again, I thank you for your help.

Formula for Month and Year-to-Date Comparisons

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.