Clicky

How to Count Rows Excluding Blank Values in Power BI

how-to Jan 30, 2024
How to Count Rows Excluding Blank Values in Power BI
Profile Image
Hi, I'm Tom Blessing. I'm an expert at helping small to mid-sized companies adopt Power BI. I'm also a recovering investment banker, with deep experience applying technology to otherwise manual data problems. I have dual degrees in Finance and Technology Management from Indiana University.

Resources to help build your fundamentals: Learning Power BI? Data fundamentals are critical for this process to be easier. I've assembled a few DataCamp courses to help.

Introduction to Power BI course: Master Power BI basics and learn to build impactful reports.

Exploratory Data Analysis in Power BI course: Learn about Power BI's Exploratory Data Analysis (EDA) and enhance your reports.

Introduction to SQL course: Learn how to create and query relational databases using SQL in just two hours.

Introduction to DAX course: Learn the fundamentals of Data Analysis Expressions (DAX) such as calculated columns, tables, and measures.

Database Design course: Learn to design databases in SQL to process, store, and organize data in a more efficient way.

Also - need better equipment? For my loyal audience in India, check out Lenovo India.

I earn a small commission on these links if you click and purchase.


In Power BI, counting rows is a fundamental operation that provides valuable information about your data.

However, dealing with blank or empty values can sometimes complicate the process.

In this blog post, we'll explore how to count rows while excluding blank values in Power BI.

We'll discuss why this is important and provide a step-by-step guide to help you achieve accurate and insightful row counts in your reports.

The Significance of Excluding Blank Rows

Blank or empty rows in your data can skew your analysis results, leading to inaccurate conclusions and decisions. Excluding these rows when counting can provide a clearer picture of your dataset and prevent misinterpretations. Here are a few scenarios where excluding blank rows is crucial:

  1. Data Quality Assurance: When assessing data quality, it's essential to identify missing or incomplete information. Counting rows while excluding blanks helps you understand the extent of data completeness.

  2. Filtering and Visualizations: In interactive reports, you may want to allow users to filter out blank rows to focus on relevant data. Accurate row counts facilitate dynamic data exploration.

  3. Calculation Accuracy: When performing calculations or aggregations, blank rows can introduce errors. Excluding them ensures accurate results.

How to Count Rows Excluding Blank Values in Power BI

Let's dive into the step-by-step process of counting rows while excluding blank values in Power BI:

Step 1: Data Preparation

Ensure that your dataset is loaded into Power BI.

Step 2: Create a New Measure

In Power BI, measures are used to perform calculations. To count rows excluding blank values, we'll create a measure using the DAX (Data Analysis Expressions) language.

In the "Modeling" tab, click on "New Measure" (or right click on the table where you want it). Name your measure something descriptive, like "Row Count Excluding Blanks." 

Step 3: Write the DAX Formula

Now, you'll write a DAX formula for your measure. The formula will use the COUNTROWS and FILTER functions to count rows while excluding blanks.

Row Count Excluding Blanks = COUNTROWS( FILTER('YourTable', NOT(ISBLANK('YourTable'[YourColumn]))) )

Replace 'YourTable' with the name of your table and 'YourColumn' with the name of the column you want to count. This formula filters out rows where the specified column is blank and then counts the remaining rows. 

Step 4: Apply Formatting (Optional)

Customize the formatting of your measure to make it user-friendly. You can format it as a whole number, add a description, or choose an appropriate display unit.

Step 5: Use the Measure in Visualizations

Now that you've created your measure, you can use it in your visualizations, tables, or cards to display the accurate row count excluding blank values. 

Step 6: Test and Publish

Test your report to ensure that the row count updates correctly and excludes blank rows. Once you're satisfied, publish your Power BI report for your audience to benefit from the improved data clarity. 

Conclusion

Counting rows while excluding blank values in Power BI is a valuable skill that enhances the accuracy and reliability of your data analysis. Whether you're performing data quality assessments, creating interactive reports, or ensuring precise calculations, this technique ensures that your insights are based on complete and meaningful data.

By following the step-by-step guide outlined in this blog post, you can easily implement row counting excluding blank values in your Power BI reports. Start applying this technique to your data analysis workflow today and experience the benefits of more accurate and insightful reports.

Read more:
Handling Power BI Card Fixed Values: Easy Guide
How to View Power BI Data Sources: Easy Way to See Your Data Linkages
Difference Between Power BI and Automate: How To Know When To Use Each One
Power BI Connect to Salesforce Objects: A Complete Guide
Selecting the First Row In A Power BI Table

Download My Free Guidebook

The 3-Step Plan for Getting Started With PowerBI

Learn the best way I've helped large and small companies adopt the best analytics tool you've ever seen. In this FREE guide, I'll show you my complete startup strategy for Power BI.

We hate SPAM. We will never sell your information, for any reason.