The COUNTROWS function counts the number of rows in the specified table, or in a table defined by an expression.
Quick Coach Video |
What it does? The COUNTROWS function counts the number of rows in the specified table, or in a table defined by an expression. Syntax COUNTBLANK( <table>) Returns A whole number. |
What is the COUNTROWS Function?
The COUNTROWS function in DAX is like a meticulous headcount—it simply counts the number of rows in a table, helping you quickly gauge the size of your dataset. This function is especially useful for getting a sense of your data volume!
Example 1: Employee Directory
Imagine you manage a company and want to know how many employees are currently listed in your directory. Here’s how your employee data might look:
Employee ID |
Employee Names |
Department |
1 |
Justin |
Editing |
2 |
Julie |
Human Resources |
3 |
Marshall |
Marketing |
4 |
Tricia |
Sales |
5 |
Austin |
IT |
To find out how many employees are in your directory, you’d use the COUNTROWS function like this:
Products Without Supplier =
COUNTROWS(Employee Directory)
Total Employees Calculation:
- Justin
- Julie
- Marshall
- Tricia
- Austin
So, how many employees are listed in the directory? That’s a total of 5 employees!
Example 2: Product Inventory
Now, let’s say you manage a store and want to check how many soda products are currently in your inventory. Here’s your inventory data:
Soda ID |
Soda Name |
Quantity in Stock |
1 |
Cola |
50 |
2 |
Lemon-Lime |
30 |
3 |
Orange Soda |
0 |
4 |
Root Beer |
20 |
5 |
Ginger Ale |
15 |
To find out how many products we have in inventory we can use the following code:
Total Sodas = COUNTROWS(Soda Inventory)
Total Sodas Calculation:
- Cola
- Lemon-Lime
- Orange Soda
- Root Beer
- Ginger Ale
So, how many types of sodas are in your inventory? That’s a total of 5 sodas! 🥤
Conclusion: Count It Up!
The COUNTROWS function in DAX is your straightforward tool for determining the number of rows in any table. Whether it’s employee directories or soda inventories, COUNTROWS helps you quickly understand the volume of your data!
So, what are you waiting for? Let’s start counting with COUNTROWS! 🥳