Hi, Madeleen Bianco
Welcome to the Microsoft community.
I am sincerely grateful to you for the patience with which we are considering this issue.
Regarding the information you provided, thank you for providing the details about your issue with calculating the number of distinct work items received per month based on data in Sheet B, filtered by period and Enquiry Type, with the results displayed on Sheet A
Below, I’ll explain the solution and provide a formula tailored to your needs using Microsoft 365’s capabilities.
It’s possible to do this with a single formula in Microsoft 365 using dynamic array functions. The formula will:
- Match the period on Sheet A (e.g., 20250101 - 20250131) to dates in Sheet B Column A.
- Filter out 'Comms Review' and 'System Controls' from Sheet B Column C.
- Count the distinct values in Sheet B Column B (reference numbers) within the filtered data.
Place this formula in the cell next to the period on Sheet A (e.g., next to 20250101 - 20250131):
=COUNTA(UNIQUE(FILTER(SheetB!B:B, (SheetB!A:A>=LEFT(SheetA!A1,8)) * (SheetB!A:A<=RIGHT(SheetA!A1,8)) * (SheetB!C:C<>"Comms Review") * (SheetB!C:C<>"System Controls"), "")))
Explanation:
- SheetA!A1: The cell on Sheet A with the period (e.g., "20250101 - 20250131"). LEFT(SheetA!A1,8) extracts the start date (20250101), and RIGHT(SheetA!A1,8) extracts the end date (20250131) by assuming a consistent format.
- SheetB!A:A: Column A on Sheet B with received dates.
- SheetB!B:B: Column B on Sheet B with reference numbers.
- SheetB!C:C: Column C on Sheet B with Enquiry Types.
- FILTER: Filters Sheet B data where:
- Dates in Column A fall between the period’s start and end dates.
- Enquiry Types in Column C are not 'Comms Review' or 'System Controls'.
- UNIQUE: Extracts distinct reference numbers from the filtered Column B.
- COUNTA: Counts the number of non-blank distinct values.
- "": Returns an empty string if no data matches the filter.
Assumptions:
- The period on Sheet A is formatted as "YYYYMMDD - YYYYMMDD" (e.g., "20250101 - 20250131").
- Dates in Sheet B Column A are in a recognizable date format (e.g., 2025/01/01 or 2025-01-01), which Excel can compare.
- Column references (A, B, C) match your data layout in Sheet B as shown in the image.
So here is the step to implement:
Prepare Sheet A:
- Ensure the period cell (e.g., A1) contains the date range (e.g., "20250101 - 20250131").
- Place the formula in the adjacent cell (e.g., B1).
Adjust Sheet B References:
- Replace SheetB!A:A, SheetB!B:B, and SheetB!C:C with the actual range if your data doesn’t span the entire column (e.g., SheetB!A2:A1000 for a specific range).
- Ensure no headers are included in the range (e.g., start from row 2 if row 1 is a header).
Test the Formula:
- Press Enter to calculate. The result should show the number of unique work items (e.g., 4 for the sample data in your image, excluding duplicates like 22101 and filtering out 'Comms Review').
- If you get an error (e.g., #VALUE!), check the date format or range references.
Handle Blanks and Errors:
- If blanks cause issues, wrap the formula in IFERROR to return 0 for invalid periods
=IFERROR(COUNTA(UNIQUE(FILTER(SheetB!B:B, (SheetB!A:A>=LEFT(SheetA!A1,8)) * (SheetB!A:A<=RIGHT(SheetA!A1,8)) * (SheetB!C:C<>"Comms Review") * (SheetB!C:C<>"System Controls"), ""))), 0)
If it’s doesn’t work:
- Date Format Issue: If dates in Sheet B Column A aren’t comparable (e.g., text like "2025/01/01"), convert them to proper dates using Data > Text to Columns > Date or a helper column with DATEVALUE.
- Range Limitation: If using entire columns (A:A) slows performance, limit to your data range (e.g., A2:A1000).
- Alternative Approach: If the single formula fails, use a two-step process:
Create a helper column in Sheet B (e.g., D) with =IF(AND(A2>=LEFT(SheetA!A$1,8),A2<=RIGHT(SheetA!A$1,8),OR(C2<>"Comms Review",C2<>"System Controls")),B2,"").
On Sheet A, use =COUNTA(UNIQUE(FILTER(SheetB!D:D,SheetB!D:D<>""))) to count distinct non-blank values.
Thank you for your kindness and understanding. If you need anything else, please feel free to contact me.
If this answer helps clarify the current situation, I would sincerely appreciate it if you could mark it as the answer. This will bring this information to the top of the feed, making it easier for other users to search for and reducing confusion for those who may be experiencing the same issue.
Thanks and Have a good day!!!
Best regards.
Sting-Ng - Microsoft Community Support Specialist.