Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
taylorpn82
Frequent Visitor

Lookup column from Direct Query that includes duplicates

Hi all, 

I need some help please - any help is greatly appreciated. 

 

I have a table called Tickets that includes Project ID as a column. I also have a second table called ProjectPortfolio that is a Direct Query (this can't be changed as I need the live data). The two tables are in the format below:

Table: Tickets   Table 2: ProjectPortfolio
     
Project ID  ViewIDProjectName
1009  1009

 Name 1

1009.1  1009Name 2
unknown  1009.1Name 3
100869  100869Name 4
100855  nullName 5
unknown  nullName 5
100855.2  100855Name 6
   100855.2Name 7
   nullName 8

 

My issue is that in the table ProjectPortfolio, there are duplicate values in both the View ID and Project Name columns and because the table is a Direct Query, I can't use the standard Remove Duplicates function in transform data.

 

I also can't clean the data in the source as this is pulled via an SQL query that I don't have access to change. 

 

Therefore, I need to clean this data in PBI before merging it with Table Tickets. I believe this needs to be done in two stages:

 

First: remove duplicates populated with a number in the View ID column whilst keeping all null rows e.g:

Note - the view ID 1009 with ProjectName equalling Name 2 has been removed.

 

ViewIDProjectName
1009 Name 1
1009.1Name 3
100869Name 4
nullName 5
nullName 5
100855Name 6
100855.2Name 7
nullName 8

 

I then need to remove duplicates from the ProjectName column where the ViewID = null. The table will then look like this:

Note - the duplicate row with null ViewID and ProjectName as Name 5 has been removed. 

ViewIDProjectName
1009 Name 1
1009.1Name 3
100869Name 4
nullName 5
100855Name 6
100855.2Name 7
nullName 8

 

The reason for doing all this is to do a lookup of the Project ID in table Tickets to the ViewID column in the table ProjectPortfolio and return the Project Name as an appended column in the table Tickets.  The expected table at the end of all of this is:

Tickets

Project IDProjectName
1009 Name 1
1009.1Name 3
unknownnull
100869Name 4
100855Name 6
unknownnull
100855.2Name 7

 

For info, I've already tried:

- Merging the two tables in their current format - this didn't work as the rows in the table Tickets are duplicated because of the duplicate rows in the ProjectPortfolio table

- Creating two duplicates of the table ProjectPortfolio, filtering out null in one version & including null values in the other and then joining them back together once I've cleared the duplicates. This led to an error saying that the function wasn't supported in Direct Query. 

 

On the face of it, this seems like it should be a simple tax but the Direct Query aspect of it makes it very difficult.

I'd be very grateful if someone could advise how I can achieve the desired result, I imagine this is using DAX in transform data but Google searches to this point have been fruitless.

 

Thanks in advance.

Pete

1 REPLY 1
lbendlin
Super User
Super User

Therefore, I need to clean this data in PBI before merging it with Table Tickets.

What's your rationale for trying to merge these tables?  Is that something you may rather want to do in the data model?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors