Skip to content

Commit 0cc0dbd

Browse files
committed
Add documentation for distinct count optimizations in DAX
1 parent b5a198f commit 0cc0dbd

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

_mydocs/dax-internals/optimization-notes/dimensions-joins.md renamed to _mydocs/dax-internals/optimization-notes/dimension-joins.md

File renamed without changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
layout: page
3+
title: Distinct Count
4+
published: true
5+
order: /60
6+
---
7+
8+
The DISTINCTCOUNT function in DAX can generate different storage engine queries depending on the complete DAX query. This page includes special notes about storage engine optimization.
9+
10+
## DISTINCTCOUNT on primary keys
11+
12+
The DISTINCTCOUNT function in DAX is automatically converted to a COUNTROWS when the argument is a key column of the table.
13+
For example, consider the following expression:
14+
```DAX
15+
DISTINCTCOUNT ( 'Product'[ProductKey] )
16+
```
17+
18+
If *ProductKey* is on the one-side of a regular one-to-many relationship, or it is marked as a key column of the table, then the code corresponds to:
19+
```DAX
20+
COUNTROWS ( 'Product' )
21+
```
22+
23+
Because COUNTROWS usually produces a more efficient query plan, this is usually an optimization that does not have side effects.

0 commit comments

Comments
 (0)