The simplest approach is using COUNTROWS and testing whether the result is equal to zero.

```COUNTROWS (
CALCULATETABLE (
'Internet Sales',
'Product Category'[Product Category Name] = "Bikes"
)
) = 0```

The CALCULATETABLE expression in the previous example can be any table expression. Usually you need to test the result of a particular filter and you use this test in the logical expression in an IF statement.

In reality, when a table is empty, the COUNTROWS function returns BLANK. Such a value is automatically converted to 0 in a scalar expression, so in a logical expression BLANK is equal to 0. However, with this knowledge in mind, we can rewrite the previous expression in this way:

```ISBLANK (
COUNTROWS (
CALCULATETABLE (
'Internet Sales',
'Product Category'[Product Category Name] = "Bikes"
)
)
)```

I think that the syntax using ISBLANK is more readable, and it could also produce some benefit in the query plan. However, when the table is not empty, you are always counting all the rows of the table, even if this is not strictly required. Microsoft added a DAX function in SQL Server 2012 SP1 Cumulative Update 4, so any build of Analysis Services 2012 and Power Pivot for Excel 2010 higher than 11.00.3368 can use the ISEMPTY syntax:

```ISEMPTY (
CALCULATETABLE (
'Internet Sales',
'Product Category'[Product Category Name]
)
)```

This syntax is simpler, meaningful and also faster. If you use DAXMD (query DAX on a Multidimensional model) the performance improvement offered by ISEMPTY is very important, and you should avoid using any COUNTROWS version to check if a table is empty.

Unfortunately, ISEMPTY is not available in Excel 2013, so using it in an Excel 2010 data model in Power Pivot will break the calculation once you upgrade the workbook to Excel 2013.

### Best Practice in Testing Empty Table in DAX

This is the order of preference for testing an empty table in DAX:

1. ISEMPTY ( <table expression> )
2. ISBLANK ( COUNTROWS ( <table expression> ) )
3. COUNTROWS ( <table expression> ) = 0

Remember that ISEMPTY is available only in SQL Server 2012 SP1 CU4 (build 11.00.3368) or later versions. At the moment of writing, it is still not available in Excel 2013 (I hope it will be introduced in a future update of Excel).

COUNTROWS Counts the number of rows in a table.

`COUNTROWS ( [<Table>] )`

CALCULATETABLE Context transition

Evaluates a table expression in a context modified by filters.

`CALCULATETABLE ( <Table> [, <Filter> [, <Filter> [, … ] ] ] )`

IF Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE.

`IF ( <LogicalTest>, <ResultIfTrue> [, <ResultIfFalse>] )`

BLANK Returns a blank.

`BLANK ( )`

ISBLANK Checks whether a value is blank, and returns TRUE or FALSE.

`ISBLANK ( <Value> )`

ISEMPTY Returns true if the specified table or table-expression is Empty.

`ISEMPTY ( <Table> )`
{"ft_lang_label":"__label__en","ft_lang_prob":0.7640625,"math_prob":0.7753783,"size":2758,"snap":"2023-40-2023-50","text_gpt3_token_len":680,"char_repetition_ratio":0.122730576,"word_repetition_ratio":0.061181433,"special_character_ratio":0.24981871,"punctuation_ratio":0.1045082,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9800507,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-07T12:52:50Z\",\"WARC-Record-ID\":\"<urn:uuid:ead66226-9187-4a3a-ae3c-0b28a2e1d790>\",\"Content-Length\":\"80647\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:848182e0-08a0-4882-ac51-004d9adf8621>\",\"WARC-Concurrent-To\":\"<urn:uuid:29190bad-6d7c-4dd8-8ae3-30ed87573333>\",\"WARC-IP-Address\":\"20.119.0.24\",\"WARC-Target-URI\":\"https://www.sqlbi.com/articles/check-empty-table-condition-with-dax/\",\"WARC-Payload-Digest\":\"sha1:UM76KYNLJ7C6JXTJVMXZGRQRSIRZ2E3S\",\"WARC-Block-Digest\":\"sha1:MZF4ECD3OI2RA3AXT25T2DTVPJOYFSXH\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100674.56_warc_CC-MAIN-20231207121942-20231207151942-00645.warc.gz\"}"}