How can I retrieve distinct values from multiple columns using Power BI

0 votes
How can I retrieve distinct values from multiple columns using Power BI?

To retrieve distinct values from multiple columns in Power BI, use the "UNION" and "SELECTCOLUMNS" DAX functions to combine columns into a single virtual table and then apply the "DISTINCT" function for unique values.
Oct 23, 2024 in Power BI by Evanjalin
• 19,330 points
220 views

1 answer to this question.

0 votes

In Power BI, obtaining unique values from certain columns can be realized by employing a variety of techniques depending on the target and level of complexity of the data. Here’s an easy instance relying on Power Query and DAX:

  • Method 1: - Power Query

Open Power Query Editor:

For Power BI Desktop, the option is on the “Home” tab. Click on “Transform Data” to trigger Power Query Editor.

Select Your Table:

In the left pane of Power Query, click the table containing the distinct values you wish to extract.

Remove Other Columns:

If only the distinct names of the columns are of concern, go ahead and select those columns. Select the columns, right-click on them, and select “Remove Other Columns.”

Remove Duplicates:

With the appropriate columns highlighted, Duplicates can be removed in Power Query Editor under the ‘Home’ tab. Click on ‘Remove Rows’ and then choose ‘Remove Duplicates.’ This will return a table with distinct values only based on the column selection mentioned.

Load Data:

Lastly, select “Close & Apply” to bring the modified data back into Power BI.

Method 2: Using DAX Since there is a need to produce a table from numerous columns and this table requires different values for some of its columns, DAX can be handy in this task as explained in the following steps:

Create a New Table:

In Power BI Desktop, navigate to the “Modeling” tab and then select “New Table.”

Write the DAX Formula:

The following DAX formula can be used to create a table with distinct values for the given columns.

DistinctValuesTable = DISTINCT(UNION(VALUES(Table[Column1]), VALUES(Table[Column2]),VALUES(Table[Column3]))) 

Substitute Table with the name of your actual table and the names Column1, Column2, and Column3 with those of columns from which you require the distinct values. This formula merges the distinct values only from the mentioned columns to form a new table. 
Look at the New Table:

Once the table is created, you can tap on it within the data model and analyze it or use it for visualization.

answered Oct 23, 2024 by pooja
• 16,840 points

Related Questions In Power BI

0 votes
1 answer

How can I extract a list of used and unused measures and columns from Power BI project folders using Python?

The extracted measures and columns, which represent ...READ MORE

answered Feb 28 in Power BI by anonymous
• 19,330 points
104 views
0 votes
1 answer

How can I preserve table data type columns from Power Query in the Power BI Data Model?

Best practices to guarantee that the defined ...READ MORE

answered Dec 23, 2024 in Power BI by pooja
• 16,840 points
91 views
0 votes
1 answer

How can I retrieve data from a website that is powered by Power BI?

Accessing imported data from a website powered ...READ MORE

answered Feb 28 in Power BI by anonymous
• 19,330 points
45 views
0 votes
1 answer

Displaying Table Schema using Power BI with Azure IoT Hub

Answering your first question, Event Hubs are ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,526 views
+1 vote
1 answer

Unable to install connector for Power Bi and PostgreSQL

I think the problem is not at ...READ MORE

answered Aug 22, 2018 in Power BI by nirvana
• 3,130 points
2,870 views
+2 votes
2 answers

Migrate power bi collection to power bi embedded

I agree with Kalgi, this method is ...READ MORE

answered Oct 11, 2018 in Power BI by Hannah
• 18,520 points
1,654 views
+1 vote
1 answer

Connect power bi desktop to dataset and create custom reports

Open power bi report nd sign in ...READ MORE

answered Oct 10, 2023 in Power BI by Monika kale

edited Mar 5 1,802 views
+1 vote
2 answers

How can I count the distinct values in a column using Power BI?

In Power BI, use the DISTINCTCOUNT DAX ...READ MORE

answered Nov 26, 2024 in Power BI by Anu
• 2,840 points
434 views
0 votes
1 answer

How can I retrieve a mapped value from a many-to-one related table in Power BI when using DirectQuery mode?

Get the associated values per multiple linked ...READ MORE

answered Jan 23 in Power BI by pooja
• 16,840 points
62 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP