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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
garich
Frequent Visitor

Display only the first record after merging 2 tables

Hi,

 

I would like to merge 2 tables below linking Customer ID and Person ID where I only need to display the first top record of Table B.

 

Table: A

IDCustomerID
1123
2456
3789

 

Table: B

IDPersonIDPRSName
1123Doe, Jane
2123Doe, Mary Jane
2456Smith, John
3789White, Robert
4789White, Robert Jr

 

 

I have this M language query which results to the Actual below and I'm stuck on what to do next...

 

 

    #"Merged Queries1" = Table.NestedJoin(#"Expanded PRS DateExtensions", {"CustomerID"}, #"PRS HistoricPersonRecords", {"PersonID"}, "PRS HistoricPersonRecords", JoinKind.LeftOuter),
    #"Expanded PRS HistoricPersonRecords" = Table.ExpandTableColumn(#"Merged Queries1", "PRS HistoricPersonRecords", {"PRSName"}, {"PRS HistoricPersonRecords.PRSName"}),

 

 

 

Expected Result:

IDCustomerIDPRSName
1123Doe, Jane
2456Smith, John
3789White, Robert

 

 

Actual Result:

IDCustomerIDPRSName
1123Doe, Jane
1123Doe, Mary Jane
2456Smith, John
3789White, Robert
3789White, Robert Jr
1 ACCEPTED SOLUTION
slorin
Super User
Super User

Hi,

Step1 = Table.NestedJoin(
#"Expanded PRS DateExtensions", {"Customer ID"},
#"PRS HistoricPersonRecords", {"PersonID"},
"PRS HistoricPersonRecords", JoinKind.LeftOuter),
Step2 = Table.AddColumn(Step1, "PRSName", each [#"PRS HistoricPersonRecords"]{0}[PRSName])

 Stéphane

View solution in original post

3 REPLIES 3
garich
Frequent Visitor

@slorin thank you! But how do I handle null values? It is throwing an error

garich_0-1701284521902.png

 

Hi,

 

try [#"PRS HistoricPersonRecords"]{0}[PRSName] otherwise null
if Table.IsEmpty([#"PRS HistoricPersonRecords"]) then null else [#"PRS HistoricPersonRecords"]{0}[PRSName]

Stéphane 

slorin
Super User
Super User

Hi,

Step1 = Table.NestedJoin(
#"Expanded PRS DateExtensions", {"Customer ID"},
#"PRS HistoricPersonRecords", {"PersonID"},
"PRS HistoricPersonRecords", JoinKind.LeftOuter),
Step2 = Table.AddColumn(Step1, "PRSName", each [#"PRS HistoricPersonRecords"]{0}[PRSName])

 Stéphane

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors