Trying to learn FILTER

charlesstricklin

Board Regular
Joined
May 6, 2013
Messages
98
Office Version
  1. 2021
Platform
  1. Windows
Hey again everybody,

I've "upgraded" to Office 2010 (sorry, not going to pay for a subscription, at least not right now) and I'm trying to learn about the FILTER function. For example data, I have (in my sheet) columns G and H, beginning at 1:

Date Amount
1/1/2023$ 112.64
2/4/2023$ 54.04
3/1/2023$ 170.85
4/8/2023$ 58.01
5/3/2023$ 10.29
6/2/2023$ 48.12
7/1/2023$ 10.61
8/1/2023$ 51.68
9/1/2023$ 177.69
9/2/2023$ 140.48
1/1/2024$ 63.62
2/1/2024$ 35.57
3/1/2024$ 59.75
4/1/2024$ 22.05
5/1/2024$ 43.34
6/1/2024$ 16.23
7/1/2024$ 105.76
8/1/2024$ 107.30
9/1/2024$ 8.08
10/1/2024$ 133.83
11/1/2024$ 30.03
12/1/2024$ 70.80


Given that the dates are in date format and not month or years by themselves, how would I use FILTER to display only contents by year, by month, or by year and month?

Many thanks in advance. I always learn something talking to you guys.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
The Filter function does not exist in 2010, it's only in 2021 & 365.
 
Upvote 0
Using Power Query. Total By Year
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
    #"Inserted Year" = Table.AddColumn(#"Changed Type", "Year", each Date.Year([Date]), Int64.Type),
    #"Inserted Month Name" = Table.AddColumn(#"Inserted Year", "Month Name", each Date.MonthName([Date]), type text),
    #"Grouped Rows" = Table.Group(#"Inserted Month Name", {"Year"}, {{"Total by Year", each List.Sum([#" Amount "]), type number}})
in
    #"Grouped Rows"

total by month

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
    #"Inserted Year" = Table.AddColumn(#"Changed Type", "Year", each Date.Year([Date]), Int64.Type),
    #"Inserted Month Name" = Table.AddColumn(#"Inserted Year", "Month Name", each Date.MonthName([Date]), type text),
    #"Grouped Rows" = Table.Group(#"Inserted Month Name", {"Month Name"}, {{"Total by Month", each List.Sum([#" Amount "]), type number}})
in
    #"Grouped Rows"



Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

- Follow this link to learn how to install Power Query in Excel 2010 / 2013.

- Follow this link for an introduction to Power Query functionality.

- Follow this link for a video which demonstrates how to use Power Query code provided.
 
Upvote 0
I've upgraded to 2021.

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

I just did, thanks.
 
Upvote 0
For year how about
Fluff.xlsm
GHIJKL
1Date Amount
201/01/2023112.64202301/01/2023112.64
304/02/202354.0404/02/202354.04
401/03/2023170.8501/03/2023170.85
508/04/202358.0108/04/202358.01
603/05/202310.2903/05/202310.29
702/06/202348.1202/06/202348.12
801/07/202310.6101/07/202310.61
901/08/202351.6801/08/202351.68
1001/09/2023177.6901/09/2023177.69
1102/09/2023140.4802/09/2023140.48
1201/01/202463.62
1301/02/202435.57
1401/03/202459.75
1501/04/202422.05
1601/05/202443.34
1701/06/202416.23
1801/07/2024105.76
1901/08/2024107.3
2001/09/20248.08
2101/10/2024133.83
2201/11/202430.03
2301/12/202470.8
24
Data
Cell Formulas
RangeFormula
K2:L11K2=FILTER(G2:H100,YEAR(G2:G100)=J2)
Dynamic array formulas.
 
Upvote 0
Solution
For year how about
Fluff.xlsm
GHIJKL
1Date Amount
201/01/2023112.64202301/01/2023112.64
304/02/202354.0404/02/202354.04
401/03/2023170.8501/03/2023170.85
508/04/202358.0108/04/202358.01
603/05/202310.2903/05/202310.29
702/06/202348.1202/06/202348.12
801/07/202310.6101/07/202310.61
901/08/202351.6801/08/202351.68
1001/09/2023177.6901/09/2023177.69
1102/09/2023140.4802/09/2023140.48
1201/01/202463.62
1301/02/202435.57
1401/03/202459.75
1501/04/202422.05
1601/05/202443.34
1701/06/202416.23
1801/07/2024105.76
1901/08/2024107.3
2001/09/20248.08
2101/10/2024133.83
2201/11/202430.03
2301/12/202470.8
24
Data
Cell Formulas
RangeFormula
K2:L11K2=FILTER(G2:H100,YEAR(G2:G100)=J2)
Dynamic array formulas.

That's great!
 
Upvote 0
I'm having trouble blending it into my real sheet, but you've shown me a direction to do. Much obliged.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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