How to Use Distinct Count and Weekly Grouping in Excel Power Pivot
Question details
The user needs to group data by weeks and calculate a distinct count simultaneously in a PivotTable.

- Product
- Excel Power Pivot
- Device & OS
- not provided
- Scenario
- Analyzing dataset trends by viewing the distinct count of items on a weekly basis.
- Observed behavior
- Standard PivotTables support weekly grouping but lack the Distinct Count function. Power Pivot allows Distinct Count but does not automatically group dates by week.
Ensure the Power Pivot add-in is enabled in your Excel COM Add-ins settings, and format your source data as a standard Excel Table before adding it to the Data Model.
Create and Relate a Calendar Table in the Data Model
By creating a dedicated calendar table with week-based fields and linking it to your main data, you can utilize Power Pivot's Distinct Count while retaining weekly groupings.
In a data model environment, time intelligence and custom grouping are best handled by a dedicated date or calendar table. This allows you to define custom time periods like weeks, fiscal quarters, or specific holidays without cluttering your original dataset.
In Excel, create a new table containing a continuous list of dates that covers the entire date range of your main data.
Add a new column to your calendar table named 'Week Start' or 'Week Number'. Use a formula like =A2-WEEKDAY(A2,2)+1 to calculate the start of the week.
Select each table, go to the Power Pivot tab on the ribbon, and click 'Add to Data Model'.
Open the Power Pivot window, switch to Diagram View, and drag the date column from your main data table to the date column in your new calendar table to establish a relationship.
Insert a PivotTable from the Data Model. Drag the 'Week Start' field from the calendar table to the Rows area, and apply the Distinct Count summarization to your target field in the Values area.

Use a Helper Column in the Source Data
If you prefer not to build a separate calendar table, you can calculate the weekly grouping directly in your source data as a workaround before loading it into Power Pivot.
Looking for a Lightweight Alternative for Data Analysis?
While Power Pivot is a specific feature of Microsoft Office, WPS Office provides a highly compatible, free, and lightweight alternative for everyday spreadsheet tasks, including robust standard PivotTables, advanced formulas, and efficient data analysis.
- 1. Download and Install: Visit the official WPS Office website to download and install the free suite on your device.
- 2. Open Your Spreadsheet: Launch WPS Spreadsheet and easily open your existing Excel workbooks to seamlessly continue your data analysis.
- 3. Create PivotTables: Use the Insert tab to add standard PivotTables and manage data grouping using built-in calculation features.

Frequently Asked Questions
Why doesn't the standard Excel PivotTable have Distinct Count?
Standard PivotTables in Excel use a basic cache memory that does not support the distinct count aggregation. To enable Distinct Count, you must check 'Add this data to the Data Model' when creating the PivotTable, which loads the data into the advanced xVelocity engine.
How do I group dates by weeks in a regular PivotTable without Power Pivot?
In a standard PivotTable, right-click any date in your Row labels, select 'Group', deselect 'Months' and 'Quarters', select 'Days', and set the 'Number of days' to 7. Note that this method prevents you from using Distinct Count.
Can I use DAX to calculate Distinct Count?
Yes. In Power Pivot, you can create a DAX measure using the DISTINCTCOUNT() function. For example: DistinctItems:=DISTINCTCOUNT([YourColumnName]). You can then drop this measure into your PivotTable alongside your calendar table's week field.




