The DISTINCTCOUNT Function
The DISTINCTCOUNT function is used to count the number of unique values in a given column of a table or a table expression. This function is very useful when you need to count the quantity of unique elements in a column, such as counting the number of distinct customers, unique products, or unique dates in your data.
Let us understand how it works - Syntax
The basic syntax of the DISTINCTCOUNT function is as follows:
Column: The column from which you want to count distinct values.
Table: The table or table expression that contains the column from which you want to count distinct values.
By Vicente Antonio Juan Magallanes -
8th September 2023 - fp20 analytics
Let's suppose we have a data table named "Sales" and you want to count the number of unique products sold, you can use the DISTINCTCOUNT function like this;
In summary, DISTINCTCOUNT is a fundamental tool for data analysis in Power BI and DAX. It provides valuable insights into the diversity and quantity of unique elements in your datasets, which can be crucial for making informed decisions and creating effective reports.
Number of Unique Products = DISTINCTCOUNT(SALES[Product])
It's important to note that DISTINCTCOUNT is primarily used in measures in Power BI to aggregate information in your reports and dashboards. You can also combine this function with other DAX functions to perform more advanced calculations on unique values in your data.