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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Netrelemo
Helper IV
Helper IV

How do I count matching merged records?

Table 1 is merged with table 2, (left outer)

1 Record in Table 1 has many records in Table 2.

 

All I want is a column with the record count of matching records in table 2. 

 

This doesn;t work

 

...

#"Merged Table" = Table.NestedJoin(#"Sorted Rows", {"ID"}, table2, {"ID"}, "table2", JoinKind.LeftOuter),
#"Expanded Table" = each Table.RowCount([ID]),

...

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Netrelemo - Try this:

 

let
    Source = Table.NestedJoin(#"Table (11)", {"Date"}, #"Table (12)", {"Date"}, "Table (12)", JoinKind.LeftOuter),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each Table.RowCount([#"Table (12)"])),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Table (12)"})
in
    #"Removed Columns"

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

@Netrelemo - Try this:

 

let
    Source = Table.NestedJoin(#"Table (11)", {"Date"}, #"Table (12)", {"Date"}, "Table (12)", JoinKind.LeftOuter),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each Table.RowCount([#"Table (12)"])),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Table (12)"})
in
    #"Removed Columns"

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I'm getting exactly the same number on every row.... meaning it's counting the number of rows in the entire table. 

I want the number of MATCHING rows. 

 

Table1 has 10,000 rows. 342 rows in Table2 match in total. 

Your formula gives me 342 on every row. 

 

I'm looking for 

Table1 row #6 has 7 matching rows in Table2

Table1 row #92 has 12 matching rows in Table2

etc

 

 

@Netrelemo - Not sure what is going on on your end, but I'm pretty sure I understood what you were after and mine works just fine. PBIX is uploaded below sig. Tables 11 and 12 and Merge1. Are you sure you referenced the Column of "Table (12)" and not the original "Table (12)". Your other table reference should have brackets [ ] around it because you are referring to the column that is created when you Merge that has the word "Table" in it for every row since each row contains a table of matching records from the second table.

Greg_Deckler_0-1598231306208.pngGreg_Deckler_1-1598231324900.png

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Rightyo, found the problem. There are a number of records without a match in table2. And due to the sorting applied they appeared first in my list, sending me down a rabbithole. 

 

Thanks. 

@Netrelemo Happens! 🙂


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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