Excel Group By: How to Group Similar Data, Ranges and Values

To group by data in Excel, insert a PivotTable, use the GROUPBY function, apply SUBTOTAL, or write a COUNTIF formula. PivotTables are fastest for ad-hoc summaries, GROUPBY is fully dynamic in Microsoft 365, and COUNTIF works in every Excel version.

  • Key Takeaway 1: Excel has no single “GROUP BY” button, but PivotTables, the GROUPBY function (Microsoft 365), and COUNTIF all replicate SQL-style grouping.
  • Key Takeaway 2: Always sort your data by the grouping column before applying Subtotal or outline grouping, or the results will be wrong.
  • Key Takeaway 3: The GROUPBY function, released to Microsoft 365 subscribers in 2023, lets you write a single formula that groups, aggregates and spills results automatically.
  • Key Takeaway 4: You can group numeric data into custom ranges (called bins) using nested IF or IFS formulas, then summarise those bins with COUNTIF or a PivotTable.
  • Key Takeaway 5: Data grouping is a core skill for data analyst roles. According to LinkedIn’s Jobs on the Rise 2024 report, data analyst positions in India grew by over 40% year-on-year, and Excel proficiency remains one of the top screening criteria.

Ways to Group Data in Excel

There are four practical ways to group by data in Excel, and each one maps to a different level of complexity. Knowing which tool to pick saves you from rebuilding your analysis from scratch when requirements change.

Think of it the same way a SQL developer thinks: GROUP BY city in a query is not one operation — it is a sort plus an aggregate. Excel gives you the same logical steps, just through different interfaces.

The Four Core Methods at a Glance

Method Best For Excel Version Required Dynamic?
PivotTable Quick summaries, drag-and-drop analysis Excel 2007 and later Refresh manually
GROUPBY Function Formula-based grouping with auto-spill Microsoft 365 (2023+) Yes, fully dynamic
SUBTOTAL + Outline Grouped row totals with collapse/expand Excel 2003 and later No
COUNTIF / SUMIF Single-column group counts or sums All versions Yes (formula-driven)

If you are preparing for a data analyst interview, expect questions on all four. Our guide to data analyst interview questions covers the Excel tasks that hiring managers actually test.

Excel Pivot Table Group By: Using a PivotTable to Group Data

Select any cell inside your dataset, go to Insert > PivotTable, and choose where to place it. Drag the column you want to group by (say, “City” or “Product Category”) into the Rows area, then drag a numeric column like “Sales” into the Values area. Excel groups same values automatically and shows a sum or count per group.

A real-world example: imagine you have 5,000 rows of e-commerce orders from Flipkart sellers across India. Drag “State” into Rows and “Order Value” into Values, set Values to Sum, and in under 10 seconds you have total revenue grouped by state. That is how to group by data in Excel at speed.

Group Rows in Excel Using the Data Outline

This is different from value-based grouping. Go to Data > Group to collapse and expand selected rows or columns manually. It is useful for hierarchical reports, like grouping quarterly rows under an annual total in a financial model. Sort your data first, select the rows for one group, click Group, and repeat for each section.

Group Same Values and Names in Excel

Grouping same values in Excel is what most people mean when they search for how to group similar data in Excel. You have a list with repeated entries like “Mumbai”, “Delhi”, “Bangalore” spread across hundreds of rows, and you want one row per city with a count or sum.

COUNTIF for Group Counts

Set up a unique list of your group labels in a separate column. If your cities are in column A (A2:A500), write this in cell C2 where B2 holds the city name you are counting:

=COUNTIF($A$2:$A$500, B2)

Copy it down the list. This gives you an Excel group by count result for every unique value. It is the simplest grouping formula in Excel and works in every version back to Excel 2003.

Using UNIQUE + COUNTIF Together

If you are on Microsoft 365, skip building the unique list manually. Use =UNIQUE(A2:A500) in an empty column to spill all distinct values automatically, then reference that spill range in COUNTIF. The two formulas together replicate a SQL SELECT city, COUNT(*) GROUP BY city in about 30 seconds.

How to Group Same Names in Excel

Sometimes your data has near-duplicates: “Tata Consultancy Services”, “TCS”, “T.C.S.” all meaning the same entity. Before grouping data in Excel, clean those names with TRIM, PROPER, or a lookup table that maps variants to a canonical name. Skipping this step is the most common mistake analysts make when grouping text data on the job.

Once names are standardised, a PivotTable will group them correctly. Or use =SUMIF($A$2:$A$500, B2, $C$2:$C$500) to sum a numeric column for each name group. This is how to club data in Excel when the goal is aggregation rather than just counting.

If you are thinking about moving from Excel-only analysis to Python, the equivalent operation in Pandas is df.groupby('City')['Sales'].sum(). Our breakdown of Pandas and NumPy explains how that logic maps across tools.

Group Data by Range in Excel with Formulas

Grouping data into numeric ranges, often called bins, is how you answer questions like “how many orders were between Rs. 500 and Rs. 1,000?” This is how to group data in Excel by range, and it requires a helper column that assigns each row to a bin label.

Using IFS to Create Bins and Group Data in Excel by Range

Suppose your order values are in column B. Add a helper column C with this formula:

=IFS(B2<500,”Under Rs.500″, B2<1000,”Rs.500-Rs.999″, B2<5000,”Rs.1,000-Rs.4,999″, B2>=5000,”Rs.5,000+”)

Now column C has a text label for every row. Run COUNTIF or a PivotTable on column C to get the count per range. This is the standard grouping formula in Excel for numeric bins, and it is what analysts use before building histograms.

Grouping Dates by Month or Quarter in a Pivot Table

Inside a PivotTable, right-click any date cell in the Rows area and choose Group. Select Months, Quarters, or Years. Excel groups all rows with the same month together automatically. This is especially useful for sales trend reports where you want monthly revenue grouped from daily transaction data.

FREQUENCY Function for Automatic Bins

The FREQUENCY function takes an array of values and an array of bin upper limits, then returns a count per bin. Select a range of cells one row taller than your bins array, type =FREQUENCY(B2:B500, {500,1000,5000}), and press Ctrl+Shift+Enter (or just Enter in Microsoft 365). It is faster than IFS when you have many bins, though the output is numbers only with no labels.

Mastering range grouping is one of the practical skills covered in serious data analytics projects, where you are often asked to segment customers or transactions into meaningful tiers.

GROUPBY Function, Subtotal and Pivot Options

This section covers the three more structured approaches that give you the most control over how to apply group by in Excel, especially for reports you will share with a manager or client.

The GROUPBY Function in Microsoft 365

GROUPBY is the closest Excel has ever come to SQL’s GROUP BY clause. Its syntax is:

=GROUPBY(row_fields, values, function, [field_headers], [total_depth], [sort_order], [filter_array])

Argument What It Does Example Value
row_fields Column(s) to group by A2:A500 (City names)
values Column to aggregate C2:C500 (Sales figures)
function Aggregation function SUM, AVERAGE, COUNT
sort_order 1 = ascending, -1 = descending -1 (highest group first)
filter_array Optional Boolean filter on rows C2:C500>1000

A working example: =GROUPBY(A2:A500, C2:C500, SUM) groups column A (city names) and sums column C (sales) for each group. The result spills into as many rows as there are unique groups. According to Microsoft’s official GROUPBY documentation, the function also supports nested grouping across multiple row fields, which makes it genuinely powerful for multi-level reports.

SUBTOTAL with Data Outline

Sort your data by the grouping column first. Then go to Data > Subtotal. Choose the column to group by, the function (Sum, Count, Average), and the column to calculate. Excel inserts subtotal rows automatically and adds an outline on the left so you can collapse groups to show only the totals.

The SUBTOTAL function itself, written as =SUBTOTAL(9, C2:C50), ignores other SUBTOTAL rows in its range, which prevents double-counting when you have nested groups. That is a behaviour that trips up beginners who try to use SUM instead.

How to Sort by Group in Excel Using Pivot Tables

Once you have a PivotTable, sorting groups is straightforward. Click the dropdown arrow on the Row Labels header and choose Sort A to Z, Sort Z to A, or More Sort Options to sort by the aggregated value. This answers how to sort by group in Excel without writing a single formula.

For keyword research work, grouping keywords by topic cluster in Excel follows the same logic: put all keywords in column A, add a “Topic” label in column B using IF or manual tagging, then pivot on column B to count how many keywords fall under each topic. That is how to group keywords in Excel for SEO or content planning workflows.

If you want to compare how Excel grouping compares to what a data scientist does in Python or R, our article on data analyst vs data scientist roles explains where the toolsets diverge. Excel grouping skills are firmly in the data analyst toolkit, and they are in demand. According to NASSCOM’s Technology Sector in India 2024 report, over 1.5 million analytics and data professionals are employed in India, with spreadsheet and SQL skills listed as foundational requirements across the majority of job descriptions. A separate World Economic Forum Future of Jobs Report 2023 ranked analytical thinking and data literacy among the top five skills employers will prioritise through 2027, reinforcing why grouping data in Excel remains a baseline competency for entry-level analyst roles.

Excel grouping is also one of the skills that transfers directly into security analytics. SOC analysts filter event logs, group alerts by source IP or threat type, and build pivot-style dashboards daily. If that career path interests you, look at what the highest-paying tech skills in 2026 look like, and where data and security overlap.

For those starting from scratch and wondering how to become a data analyst in India, our Hindi-language guide on data analyst kaise bane walks through the full path, including which Excel skills to prioritise first.

Frequently Asked Questions

How do I group data in Excel?

Select your dataset and insert a PivotTable (Insert > PivotTable), then drag the column you want to group by into the Rows area and a numeric column into Values. Excel groups same values automatically and shows a total per group. Alternatively, use the GROUPBY function in Microsoft 365 or COUNTIF with a unique values list for a formula-based approach.

How do I group same values in Excel?

Use =COUNTIF($A$2:$A$500, B2) where column B holds your unique group labels and column A is the full data column. This returns a count for each unique value. For sums, use SUMIF with the same structure. A PivotTable does the same thing visually without any formula writing.

Is there a GROUP BY formula in Excel?

Yes. The GROUPBY function, available in Microsoft 365 from 2023 onwards, lets you write a formula like =GROUPBY(A2:A500, C2:C500, SUM) to group and aggregate data in one step. For older Excel versions, combine UNIQUE, COUNTIF, and SUMIF to achieve the same result across multiple cells.

How do I group data by range in Excel?

Add a helper column with an IFS formula that assigns each row a bin label, such as “Rs.500-Rs.999” or “Under Rs.500”, based on the numeric value in another column. Then run COUNTIF or a PivotTable on the helper column to count how many rows fall into each range. The FREQUENCY function handles this automatically if you only need counts.

How do I sort groups in Excel?

In a PivotTable, click the dropdown on the Row Labels header and choose a sort option, including sorting by the aggregated value rather than the label. In a GROUPBY formula, set the sort_order argument to 1 for ascending or -1 for descending. For Subtotal outlines, sort the data by the grouping column before applying subtotals so groups appear in the right order.

Grouping data in Excel is one of those skills that looks simple but reveals its depth fast once you are dealing with messy, real-world datasets. Start with PivotTables for speed, learn COUNTIF and SUMIF for formula flexibility, and move to GROUPBY when you need dynamic, reportable outputs. Here are three actions you can take this week:

  1. Open any dataset you have, even a personal expense log, and build a PivotTable that groups rows by category and shows a sum. Get the muscle memory first.
  2. Try the GROUPBY function if you have Microsoft 365. Write =GROUPBY(A2:A100, B2:B100, SUM) on a test sheet and experiment with the sort_order argument.
  3. Explore how these grouping skills apply in a real analytics or security role. The 3.0 University online certification courses in AI, Cybersecurity, and Data cover practical tools including Excel, Python, and SIEM dashboards. If you want to see where data skills meet security work, the EC-Council Certified SOC Analyst course is a strong next step, because SOC analysts group and filter log data every single shift.

Last updated: October 2026. Reviewed by the 3University editorial team.

We create, review, and maintain educational content covering Cybersecurity, Ethical Hacking, Artificial Intelligence, Blockchain, Web3, and emerging technologies.

Read More Articles