13.8Counting, finding the largest, replacing blanks
Beyond SUM and COUNTROWS, which you already know, a few functions count in other ways, find the largest or the smallest value, and replace a blank value.
13.8.1COUNT, COUNTA and COUNTBLANK
In Excel
| DAX | COUNT | COUNTA | COUNTBLANK |
|---|---|---|---|
| Excel | COUNT | COUNTA | COUNTBLANK |
| Match |
You need them to check an extraction before you trust it, for example to find out whether some customer names are missing.
COUNT counts the non-blank values of a column of numbers, dates or text. COUNTA does the same, and also counts TRUE or FALSE values. COUNTBLANK counts the blank values.
| The non-blank values | COUNT( <column> ) |
|---|---|
| With TRUE and FALSE | COUNTA( <column> ) |
| The blank values | COUNTBLANK( <column> ) |
Each one expects a single argument, a column written with its table, like Customers[Name].
- COUNT( Sales[Qty] ) returns 12.
- COUNTA( Customers[Name] ) returns 7.
- COUNTBLANK( Customers[Name] ) returns a blank value.
| [COUNT] | [COUNTA] | [COUNTBLANK] | |
|---|---|---|---|
| 1 | 12 | 7 |
This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.
All 7 customers have a name. So COUNTBLANK finds no blank value, and it returns a blank value, not 0. To show 0, write COALESCE( COUNTBLANK( Customers[Name] ), 0 ).
Unlike COUNTROWS, these three functions count within a column, not the rows of a table.
Practice
Each exercise is solved with the function you just discovered. Two exercises per function, a direct use and a combined use, from easiest to hardest, on data other than the course data. Pick the right formula out of five.
Direct useMeasureDifficulty
A class has handed in its papers. In the “Grades” table, the grade stays blank when the student did not hand in a paper. Write the “Papers Handed In” measure, which counts the grades in the “Grade” column.
Grades Student Grade Alma 14 Bilal Chloé 9 Dario 17 Eva Which formula should you write for “Papers Handed In”?
Combined useMeasureDifficulty
The teacher wants to know the share of papers handed in, among the students of the “Grades” table. A paper handed in has a grade in the “Grade” column. Write the “Hand-In Rate” measure.
Grades Student Grade Alma 14 Bilal Chloé 9 Dario 17 Eva Direct useMeasureDifficulty
A sports club records in the “Members” table whether each membership fee is paid, with TRUE or FALSE. The column stays blank when it is not known yet. Write the “Known Fees” measure, which counts the filled-in values of the “Paid” column.
Members Name Paid Inès TRUE Hugo FALSE Jade Karim TRUE Combined useMeasureDifficulty
The club wants to know for how many members it is still unknown whether the fee is paid. In the “Members” table, their value in the “Paid” column is blank. Write the “Unknown Fees” measure.
Members Name Paid Inès TRUE Hugo FALSE Jade Karim TRUE Direct useMeasureDifficulty
A carrier tracks its parcels in the “Deliveries” table. The delivery date stays blank as long as the parcel has not arrived. Write the “Pending Parcels” measure, which counts the blank dates.
Deliveries Parcel Delivery Date C-101 3/2/2026 C-102 C-103 C-104 3/5/2026 Combined useMeasureDifficulty
The carrier wants to know the share of parcels still on their way, among all the parcels of the “Deliveries” table. A parcel on its way has no date in the “Delivery Date” column. Write the “Pending Share” measure.
Deliveries Parcel Delivery Date C-101 3/2/2026 C-102 C-103 C-104 3/5/2026
The rest of this lesson is part of izyDAX Pro
You have just read the first section. The next 2, their animations, the exercises and the summary are waiting for you with izyDAX Pro, in a single payment.