Power Query Problems

How to Count Activities by Person Using Power Query in Excel

Anum MushtaqAnum Mushtaq Nov 3, 2026 870 views

Question details

The user needs to count specific activities assigned to individuals when the activity data is spread across multiple columns.

How to Count Activities by Person Using Power Query in Excel
Product
Excel
Device & OS
not provided
Scenario
Data analysis and reporting where activity records are stored in a wide format, making standard COUNTIF formulas or PivotTables ineffective.
Observed behavior
The user wants to normalize the multi-column activity data to accurately summarize and count the number of activities per person.
Before you start

Ensure your data is formatted as an Excel Table (by pressing Ctrl+T) before loading it into Power Query. This ensures that any future rows or columns added will dynamically update in your final report.

Solution 1Recommended

Use Power Query to Unpivot Columns and Create a PivotTable

Normalize your wide data by unpivoting the activity columns in Power Query, which then allows you to easily summarize the data using a standard PivotTable.

When activities are spread across several columns, traditional functions like COUNTIF become complex and difficult to maintain. Power Query solves this by transforming your 'wide' data into a 'flat' format, which is the ideal structure for PivotTable analysis.

1
Load Data to Power Query

Select any cell inside your data table, navigate to the 'Data' tab on the Excel ribbon, and click 'From Table/Range' to open the Power Query Editor.

2
Unpivot the Activity Columns

In the Power Query Editor, right-click the column header containing the person's name and select 'Unpivot Other Columns' from the context menu. This converts all activity columns into a pair of 'Attribute' and 'Value' columns.

3
Clean Up the Columns

If the 'Attribute' column simply contains generic headers like 'Activity 1' or 'Activity 2' and is no longer needed, right-click it and select 'Remove'. Rename the 'Value' column to 'Activities' by double-clicking its header.

4
Load the Normalized Data

Click 'Close & Load To...' located on the Home tab. In the dialog box, select 'PivotTable Report' and choose whether to place it on a new or existing worksheet.

5
Count the Activities

In the PivotTable Fields pane, drag the person's name field into the 'Rows' area. Drag the 'Activities' field into both the 'Columns' area and the 'Values' area (ensure it says 'Count of Activities') to view the summarized totals.

Use Power Query to Unpivot Columns and Create a PivotTable
Data Normalization Advantage: By unpivoting your data, you create a robust, scalable dataset. Any new activity columns added to your source table will automatically be normalized upon refreshing.
Free Microsoft Office alternative

Analyze Data Seamlessly with WPS Office

If you are looking for a highly capable, cost-effective alternative for handling complex data analysis and PivotTables, WPS Office provides a lightweight and free solution. It offers exceptional performance without the heavy subscription fees.

  1. 1. Download and Install: Get the free WPS Office suite from the official website and complete the quick installation.
  2. 2. Open Your Excel File: Launch WPS Spreadsheets and open your existing .xlsx file without worrying about format loss.
  3. 3. Utilize Powerful PivotTables: Go to the Insert tab and select PivotTable to immediately start summarizing your structured data effortlessly.
100% compatible with Microsoft Excel (.xlsx) formats, ensuring your existing data tables and PivotTables load perfectly.Intuitive and familiar spreadsheet interface with zero learning curve for data manipulation.Lightweight installation that runs incredibly fast, even on older computers.Completely free access to robust data analysis, filtering, and charting tools.
QA img-9

Frequently Asked Questions

Why can't I just use COUNTIF for multiple activity columns?

While possible, using COUNTIF across many scattered columns requires complex, array-like formulas that are prone to errors and difficult to maintain. Normalizing the data first ensures counting is accurate, scalable, and completely automated via PivotTables.

What exactly does 'Unpivot Other Columns' do in Power Query?

It takes multiple columns of horizontal data and transforms them into vertical rows. It pairs each distinct value with its corresponding row identifier (like a person's name), turning wide, report-style data into a flat database format.

Will the PivotTable update automatically if I add new activities?

Yes. As long as your original source data is formatted as an Excel Table, you simply need to right-click your PivotTable and select 'Refresh'. Power Query will automatically process the new columns or rows and update your counts.