How to Get Number of Records in Tableau

Cody Schneider••7 min read

Finding the total number of records in your dataset is one of the most fundamental tasks in Tableau. While it seems simple, Tableau offers a few different ways to get this number, and the best method has changed with recent updates to its data model. This article will walk you through the old default method, the new best practice for counting rows, and other powerful counting functions for more specific analyses.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

The Classic Method: The Number of Records Field

If you've used older versions of Tableau, you're likely familiar with the automatically generated Number of Records field. This field is a simple calculated field that contains the value 1 for every single row in your data source.

When you drag Number of Records onto the view - whether on the Columns or Rows shelf, or onto the Text marks card - Tableau's default aggregation is SUM(). This sums the value 1 for every row, giving you the total count.

How to Use It:

  1. In the Data pane (on the left side), find the field named Number of Records. It is usually located at the very top of your measures.
  2. Drag Number of Records onto the canvas or onto the Text box in the Marks card.
  3. Tableau automatically applies the SUM() aggregation, and you will see the total count of all records in your dataset.

Why Is Number of Records Being Phased Out?

You might notice Number of Records isn't always there, especially in newer workbooks. Tableau is moving away from this for an important reason: the introduction of Relationships in the data model.

Previously, when you combined tables in Tableau, you used joins. All your tables were flattened into one single, wide data source before analysis. In this context, a row was a row, and Number of Records was predictable.

With relationships (the "noodle" connectors), tables remain separate until you build a visualization. They are not merged into a single table. Because of this, a simple SUM(1) can be ambiguous. Are you counting records from the Orders table or the Customers table? They could have different counts (one customer can have many orders).

Therefore, Number of Records has been retired in favor of more explicit counting methods to avoid confusion when relating multiple tables.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Best Practice: Manually Creating a Row Count

The new, recommended approach is to create your own "number of records" calculation. This gives you complete control and ensures your logic is consistent, no matter how your data model is set up. The process is almost as simple as the original method.

Steps to Create a Row Count Calculation:

  1. Right-click on an empty space in the Data pane and select Create Calculated Field.
  2. Name your new field something clear, like "Total Rows" or "Row Count."
  3. In the formula box, simply type the number:
  4. Click OK.

You now have a field that functions exactly like the old Number of Records field. When you drag it into the view, Tableau will default to SUM([Total Rows]), giving you the count of every record in your principal table.

This is considered the best practice because it’s explicit, reliable across different versions of Tableau, and works predictably even with complex data models built on relationships.

Counting More Than Just Records: COUNT vs. COUNTD

Sometimes you don't need the total number of rows, you need to count how many distinct or unique values of a dimension you have. For this, COUNT and COUNTD come into play.

COUNT: Counting Non-Null Values

COUNT([Dimension or Measure])

counts how many rows have a non-null value for that specific field. For example, COUNT([Order ID]) would give you the total number of orders. This is often an alternative to SUM(1), but it's only identical if the chosen field (like Order ID) has a value in every single row.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

COUNTD: Counting Distinct Values

COUNTD([Dimension])

is extremely useful. It counts the number of unique values in a dimension. This helps you answer questions that go beyond just counting rows.

Example: How many unique customers made a purchase? Let's say your dataset contains 1,000 orders. SUM([Total Rows]) would give you 1,000. But if many of those orders came from repeat customers, the number of unique customers would be much lower.

To find out, you would use a calculation like:

COUNTD([Customer ID])

Using COUNTD() gives you a more nuanced understanding of your data. You can compare the total number of transactions (COUNT([Order ID])) to the total number of customers (COUNTD([Customer Name])) to see how frequently your average customer makes a purchase.

What Happened to My Number of Records in a Relational Model?

If you connect two or more tables using relationships in Tableau, you’ll notice something interesting: Number of Records disappears, but Tableau auto-generates a new count field for each table.

For example, if you relate an Orders table and a Returns table, you’ll see these fields in your Data pane:

  • Orders (Count)
  • Returns (Count)

These fields represent a count of all records from their respective tables. Using Orders (Count) is equivalent to creating your own SUM(1) calculation and using it in a visualization that queries the Orders table. Tableau does this to eliminate ambiguity. It forces you to be specific about which set of records you intend to count, which is essential for accurate analysis when working with related but separate data tables.

When should you use the <TableName> (Count) field?

It’s perfectly fine to use this auto-generated field. It’s an explicit and reliable way to count records from a specific table within a known data model. The main reason some developers still prefer creating their own SUM(1) calculation is for universal consistency. A field named "Row Count" always means the same thing, whereas Orders (Count) is specific to a data source with an Orders table.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Advanced Counting: Using an IF Statement

What if you only want to count records that meet a certain condition? This is where you can combine a sum with a conditional statement to get a powerful, flexible count.

For example, you want to count how many orders totaled more than $500. A simple SUM(1) will count everything. But you can create a calculated field to solve this.

Example: Counting High-Value Orders

  1. Create a new calculated field and name it "Large Order Count."
  2. Use the following formula:
  3. This calculation goes row-by-row: if the value in the Sales field is greater than 500, it returns a 1. If not, it returns a 0. SUM() then adds up all the 1s, giving you the total count of large orders.

This approach is incredibly flexible for creating conditional counts without having to apply filters that would remove data from your entire view.

Final Thoughts

Counting records in Tableau is a simple task that reveals how its data model has evolved. While the old Number of Records field was easy, it lacked clarity in modern, relationship-based data sources. The best and most robust method today is to create your own calculated field containing 1 and summing it as needed. For more advanced needs, functions like COUNTD() and conditional calculations provide the flexibility to count exactly what matters to your analysis.

Of course, becoming proficient in calculations like these requires deep familiarity with whatever analytics tool you're using. We created Graphed because we believe your time is better spent getting insights, not wrestling with formula syntax. Instead of building different calculations for records, customers, and large orders, you can simply connect your data sources once and ask "How many total orders last quarter?" or "Compare the count of unique customers from our Facebook campaigns vs. our Google Ads campaigns." We handle the underlying logic and instantly build the visualization for you, getting you from question to answer in seconds.

Related Articles