You are learning Sorting and Filtering in MS Excel
How to filter dates by specific periods (e.g., this week, last month)?
Here are two methods to filter dates by specific periods in Excel:
Method 1: Using AutoFilter with Custom Dates
1. Select your data table: Make sure the column containing your dates is highlighted.
2. Activate the Filter: Go to the "Data" tab and click on "Filter" in the "Sort & Filter" group. Filter arrows will appear on the header row of your data table.
3. Click the filter arrow for the date column. A dropdown menu with filtering options will appear.
4. Choose "Custom Filter..." from the menu.
5. Set up your date criteria:
- In the "Criteria" section, you'll see two rows - one for "Greater than or equal to" and another for "Less than or equal to."
- Depending on your desired period:
- For "This Week":
- In the "Greater than or equal to" field, enter `=TODAY()-WEEKNUM(TODAY())+1`. This formula calculates the beginning of the current week.
- In the "Less than or equal to" field, enter `=TODAY()`. This selects all dates up to today.
- For "Last Month":
- In the "Greater than or equal to" field, enter `=EOMONTH(TODAY(),-1)+1`. This formula calculates the first day of last month.
- In the "Less than or equal to" field, enter `=EOMONTH(TODAY(),-1)`. This selects all dates in the previous month.
- You can adjust these formulas for other periods by using Excel date functions like DATE, MONTH, YEAR, etc.
6. Click OK: Once you've defined your criteria, click "OK" to apply the filter.
Method 2: Using Advanced Filter
1. Copy your data table: Select your entire data table and copy it (Ctrl+C).
2. Choose a destination for filtered data: In a blank area of your worksheet, choose a cell where you want the filtered data to appear.
3. Go to Data > Advanced ([Data] tab > [Advanced] button)): Navigate to the "Data" tab and click on "Advanced" in the "Sort & Filter" group.
4. Set up the criteria:
- In the "Copy to" range, enter the cell address where you want your filtered data to be placed (the cell you chose in step 2).
- In the "Criteria range" section, click the "Collapse" button (if expanded) and then select a blank area below your copied data table. This will be where you define your filtering criteria.
5. Create your filter criteria table:
- In the first row (header row) of your criteria table, label the column containing your dates as "Date."
- In the second row, enter the following formula in the cell corresponding to the "Date" header: `=TODAY()-WEEKNUM(TODAY())+1` (for this week) or `=EOMONTH(TODAY(),-1)+1` (for last month).
- In the third row, enter `=TODAY()` (for this week) or `=EOMONTH(TODAY(),-1)` (for last month).
- You can adjust these formulas for other periods as needed.
6. Copy criteria table down: Drag the formula in the "Date" criteria cell down to apply it to all rows you want to filter.
7. Select the checkbox for "Copy only unique records" (optional).
8. Click OK: Once everything is set up, click "OK" to apply the advanced filter and display your date-filtered data.
These methods allow you to filter your data by various date periods. Remember to adjust the formulas based on the specific timeframe you're interested in.