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
• 10,680 points
137 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
• 11,310 points

Related Questions In Power BI

0 votes
0 answers
0 votes
0 answers

How can I create dynamic parameters in Power BI using DAX?

How can I create dynamic parameters in ...READ MORE

Oct 14, 2024 in Power BI by anonymous
• 10,680 points
110 views
+2 votes
2 answers

How can I create dynamic parameters in Power BI using DAX?

Similarly, in Power BI, utilizing DAX, one ...READ MORE

answered Oct 22, 2024 in Power BI by pooja
• 11,310 points
303 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,410 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,793 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,568 views
+1 vote
1 answer

Connect power bi desktop to dataset and create custom reports

Yes using Power BI REST API to ...READ MORE

answered Sep 18, 2018 in Power BI by Kalgi
• 52,350 points
1,701 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
• 1,200 points
309 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
• 11,310 points
43 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