LOGIC/SUM/FILTER Help

Walker_Ice

Board Regular
Joined
Oct 6, 2023
Messages
50
Office Version
  1. 2021
Platform
  1. MacOS
Hi Everyone,

I have a table that is looking to sum up all of the expenses for the fiscal years of a specific year, except now I would like to be able to select "All" and sum up all of the data available for those 3 months specifically in that fiscal quarter.

Below is the code I have which works for the specific year. Can someone help with modifying it to be able to select "All" from the dropdown list.

TEsting_Excel_File.xlsx
ABCDEF
1Expense_DatesExpense_TotalSpent
22/4/21$858.00FISCAL YEAR QUARTERS:2023
33/13/23$750.00Total Cost
46/17/22$75,000.00JFM$126,560.00
56/7/23$7,000.00AMJ$13,844.00
67/10/23$85,000.00JAS$85,000.00
73/31/24$851,002.00OND$77.00
85/26/23$6,520.00Year Total:$225,481.00
92/18/23$1,000.00
106/1/23$324.00
112/18/24$4,243.00
123/18/23$4,537.00
135/28/22$8,789.00
142/8/23$75.00
153/3/23$433.00
161/4/21$2,224.00
172/14/23$42,235.00
1811/1/23$77.00
191/3/22$78.00
202/25/23$987.00
216/26/25$4,567.00
223/10/23$76,543.00
Sheet3
Cell Formulas
RangeFormula
F4F4=SUMIFS( $B$2:$B$22, $A$2:$A$22, ">=" & DATE($F$2, 1, 1), $A$2:$A$22, "<=" & EOMONTH(DATE($F$2, 3, 1), 0) )
F5F5=SUMIFS( $B$2:$B$22, $A$2:$A$22, ">=" & DATE($F$2, 4, 1), $A$2:$A$22, "<=" & EOMONTH(DATE($F$2, 6, 1), 0) )
F6F6=SUMIFS( $B$2:$B$22, $A$2:$A$22, ">=" & DATE($F$2, 7, 1), $A$2:$A$22, "<=" & EOMONTH(DATE($F$2, 9, 1), 0) )
F7F7=SUMIFS( $B$2:$B$22, $A$2:$A$22, ">=" & DATE($F$2, 10, 1), $A$2:$A$22, "<=" & EOMONTH(DATE($F$2, 12, 1), 0) )
F8F8=SUM(F4:F7)
Named Ranges
NameRefers ToCells
Expense_Dates=Sheet3!$A$2:$A$25F4:F7
Expense_TotalSpent=Sheet3!$B$2:$B$26F4:F7
Cells with Data Validation
CellAllowCriteria
F2ListAll,2022,2023,2024
 
But when I tried modifying it for "All" i never got it to work.

Then I ended up with the formula below, and I got it to work for "All" but it doesn't work for any specific year. TRAPPED IN LOOP lol.

=IFERROR( IF( $N$33="All", SUM(FILTER(Expense_TotalSpent, ROUNDUP(MONTH(Expense_Dates)/3, 0) = ROWS($K$35:$K35))), SUMIFS(Expense_TotalSpent, YEAR(Expense_Dates), $N$33, ROUNDUP(MONTH(Expense_Dates)/3, 0), ROWS($K$35:$K35)) ), 0)

Can you help me find out what I am getting wrong? I would truly appreciate it. 🙏
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
If you really want 2 formulas based on using an if statement the below will work. It essentially uses your original formula if <> "All". The only difference being that you can copy it down to all quarters.

Excel Formula:
=IFERROR( IF(
$N$33="All",
SUM(FILTER(Expense_TotalSpent, ROUNDUP(MONTH(Expense_Dates)/3, 0) = ROWS($K$35:$K35))),
SUMIFS(Expense_TotalSpent,
                  Expense_Dates,">=" & DATE($N$33, ROWS($K$35:K35)*3-2, 1),
                  Expense_Dates,"<=" & EOMONTH(DATE($N$33, ROWS($K$35:K35)*3, 1),0))),
0)
 
Upvote 0
Here is another single formula version:
(If you are using an older version of Excel you would need to change the SUM to SUMPRODUCT)

Excel Formula:
=SUM(
Expense_TotalSpent
*IF($N$33="All",1,(YEAR(Expense_Dates)=$N$33))
*(ROUNDUP(MONTH(Expense_Dates)/3,0)=ROWS($K$35:$K35)))
 
Upvote 0
Solution
They both work beautifully!! Thank you so much for your support! I'm trying to get better at using Excel and you have been a tremendous help in this recent excel journey of mine. I appreciate your time and effort.
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

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