Dax Function: DISTINCT (table)
Category: Table Manipulation Functions
The DISTINCT function in Power BI, when applied to a table, creates a new table that contains only the unique rows from the input table. It is used for deduplication and ensures that all rows in the resulting table are distinct.
Purpose
To eliminate duplicate rows in a table.
Simplifies aggregation and grouping operations by working with unique datasets.
Useful for filtering, creating dimension tables, and performing unique-row calculations.
Type of Calculations
Performs deduplication of rows based on all columns in the input table.
Ensures that each row in the output table is unique, preserving data consistency.
Practical Use Cases
Building Dimension Tables: Create tables with unique rows for establishing relationships in data models.
Data Validation: Identify and work with unique records from datasets with potential duplicates.
Advanced Aggregation: Use unique rows in conjunction with DAX aggregation functions for more accurate reporting.
DISTINCT ( table )
| Parameter | Type | Description |
|---|---|---|
| table | Table | The input table from which distinct rows will be extracted. |
How Does DISTINCT (table) Dax Works
Row-by-Row Evaluation: The function examines each row in the input table.
Deduplication: Duplicate rows (rows that are identical across all columns) are removed.
Output Table: A new table is created with the remaining unique rows.
Key Points
Works at the row level, considering all columns in the input table.
The result is a table object that can be used in DAX calculations or visuals.
What Does It Return?
Table: A new table containing only the unique rows from the input table.
When Should We Use It?
Dimension Creation: Use when creating dimension tables from transactional data.
Data Quality Assurance: Validate datasets to ensure no duplicate rows are present.
Simplified Filtering: Generate distinct datasets for slicers or advanced reporting needs.
Examples
Basic Usage :
Removing duplicate rows from a table:
DISTINCT ( Sales )
Result: Returns a table containing all unique rows from the Sales table.
Column Usage
Combine with calculated columns:
DISTINCT (
ADDCOLUMNS(
Sales,
"Discounted Amount", Sales[Amount] * (1 - Sales[Discount])
)
)
Result: Returns a table with distinct rows and a calculated column for Discounted Amount.
Advanced Usage
Combine with filtering and aggregation:
SUMMARIZE (
DISTINCT ( Sales ),
Sales[Region],
"Total Sales", SUM ( Sales[Amount] )
)
Result: A summary table showing total sales for each unique region.
Tips and Tricks
Apply only to tables with potential duplicate rows; unnecessary usage can impact performance.
Combine with
FILTERorCALCULATETABLEfor more refined datasets.Large Tables: Handling large datasets can affect performance due to the deduplication process.
Column Granularity: Ensure that all columns in the table are necessary for defining row uniqueness.
Performance Impact of DISTINCT (table) DAX Function:
Optimize Queries: For large datasets, combine with pre-filtering or aggregations to reduce processing overhead.
Avoid Redundancy: Use only when distinct rows are explicitly required.
Related Functions You Might Need
| Function | Description |
|---|---|
VALUES | Returns unique rows or values from a table or column, including blanks. |
SUMMARIZE | Creates a summary table with grouped values and aggregations. |
DISTINCTCOUNT | Counts the number of distinct values in a column. |
FILTER | Returns a filtered subset of a table. |
Want to Learn More?
For more information, check out the official Microsoft documentation for DISTINCT (table) You can also experiment with this function in your Power BI reports to explore its capabilities.
Unlock the full capabilities of Power BI and elevate your data insights with our specialized consulting services. Whether you need guidance on advanced DAX functions like those highlighted here, support in designing interactive dashboards, or expertise in optimizing data models for enhanced performance, our experienced Power BI consultants are equipped to deliver customized solutions for your business. Explore our Power BI Consulting Services page to discover how we can help your organization make smarter, data-driven decisions.
It returns a new table containing only the unique rows from the input table by removing duplicates.
Yes, DISTINCT can be applied to calculated tables to remove duplicates based on the calculation results.
Blank rows are treated as unique rows and are included in the output.
Yes, distinctions in case (e.g., “ABC” vs. “abc”) result in separate rows being treated as unique.
DISTINCT removes duplicates and returns only unique rows, while VALUES can return all rows, including duplicates, under certain contexts.