Returns an estimated count of the unique values in a column. This function invokes a corresponding aggregation operation in the data source, optimized for query performance but with slightly reduced accuracy. You can use APPROXIMATEDISTINCTCOUNT with the following data sources: Azure SQL, Azure SQL Data Warehouse, BigQuery, Databricks, and Snowflake. Note that this function requires DirectQuery mode. Import mode and dual storage mode are not supported.


Parameter Attributes Description

The column for which the distinct values are counted.

Return values

Scalar A single integer value.

The approximate number of distinct values in ColumnName.


The SQL query generated uses the APPROX_COUNT_DISTINCT in Transact-SQL to obtain the result.

» 2 related functions


--  APPROXIMATEDISTINCTCOUNT can be used only in models using DirectQuery
--  on Azure SQL or Azure SQL Data Warehouse.
--  It uses the faster (but less accurate) version of DISTINCT available 
--  on these engines to compute distinct counts: APPROX_COUNT_DISTINCT 
--  The function implementation guarantees up to a 2% error rate within 
--  a 97% probability.
    MEASURE Sales[#Prods] = DISTINCTCOUNT ( Sales[ProductKey] )
    MEASURE Sales[#App Prods] = APPROXIMATEDISTINCTCOUNT ( Sales[ProductKey] )
    'Date'[Calendar Year],
    TREATAS ( { "CY 2007", "CY 2008", "CY 2009" }, 'Date'[Calendar Year] ),
    "#Prods",       [#Prods],
    "#App Prods",   [#App Prods]

Related functions

Other related functions are:

Last update: May 23, 2024   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo, Kenneth Barber

Microsoft documentation:

2018-2024 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.


Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.


This function is deprecated. Jump to the Alternatives section to see the function to use.


A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.


This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.


Want to improve the content of APPROXIMATEDISTINCTCOUNT? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.