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.
I have Table 1 that contains a column of ALL of my employees:
Employee ID | Sales Value |
1 | 25 |
2 | 50 |
3 | 75 |
4 | 100 |
5 | 100 |
I have Table 2 that contains a SUBSET of employees and their info:
Employee ID | First Name | Last Name |
2 | Jon | Doe |
4 | Jane | Doe |
I want to filter my Table 1, so that it only contains rows that show up in Table 2. Table 1 after the filter should look like this:
Employee ID | Sales Value |
2 | 50 |
4 | 100 |
How do I achieve this? Bonus: is there a way to achieve this without doing a Join? The tables are millions of rows long, so I don't know how join would impact performance.
Solved! Go to Solution.
Hi @rahme
An inner join should do it and is quite probably the best performing option
Place the following M code in a blank query to see the steps.
let
Source = Table.NestedJoin(Table1, {"Employee ID"}, Table2, {"Employee ID"}, "Table2", JoinKind.Inner),
#"Removed Columns" = Table.RemoveColumns(Source,{"Table2"})
in
#"Removed Columns"
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
Hi @rahme ,
You can also try this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIyVYrViVYyAjJNDcBMYyDTHCJqAmQaGkCETWHsWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Employee ID" = _t, #"Sales Value" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Employee ID", Int64.Type}, {"Sales Value", Int64.Type}}),
#"Filtered Table1" = Table.SelectRows(#"Changed Type", each List.Contains(#"Table2"[Employee ID],[Employee ID]))
in
#"Filtered Table1"
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @rahme
An inner join should do it and is quite probably the best performing option
Place the following M code in a blank query to see the steps.
let
Source = Table.NestedJoin(Table1, {"Employee ID"}, Table2, {"Employee ID"}, "Table2", JoinKind.Inner),
#"Removed Columns" = Table.RemoveColumns(Source,{"Table2"})
in
#"Removed Columns"
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.