Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi,
I'm looking for a way to join 2 table in Power Query. This should be a left join that only returns the first record of the right table. See my example below:
Solved! Go to Solution.
Yes, you can use the "Aggregate"-tab instead of the "Expand"-tab, choose any of the defualt actions and replace the function by "List.First".
Table.AggregateTableColumn(#"Grouped Rows", "Count", {{"Case", List.Count, "Count of Case"}})
will become
Table.AggregateTableColumn(#"Grouped Rows", "Count", {{"Case", List.First, "Count of Case"}})
But performance might be a pain: https://www.thebiccountant.com/2019/10/28/performance-tip-for-aggregations-after-joins-in-power-quer...
Better just to reference the lookup table then, do the distinct manually and uncheck "load to data model" if you're going to use that table just for this purpose.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Use the fuzzy match when merging queries and set number of matches to 1. Match threshold to 1.0
Use Table.Distinct(#"Right table", {"TrackingID"}) in the merge (by tweaking the code) or remove duplicates with the UI before the merge.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
That may work in my query, but I'm not sure how to apply this on the query below.
#"Merged Queries" = Table.NestedJoin(#"Renamed Columns", {"Shipment Number"}, BKM_UPS_D2L_carton_details_lookup, {"TrackingID"}, "BKM_UPS_D2L_carton_details_lookup", JoinKind.LeftOuter),
#"Expanded BKM_UPS_D2L_carton_details_lookup" = Table.ExpandTableColumn(#"Merged Queries", "BKM_UPS_D2L_carton_details_lookup", {"Virtual_Warehouse"}, {"BKM_UPS_D2L_carton_details_lookup.Virtual_Warehouse"}),
#"Renamed Columns2" = Table.RenameColumns(#"Expanded BKM_UPS_D2L_carton_details_lookup",{{"BKM_UPS_D2L_carton_details_lookup.Virtual_Warehouse", "Location TrackingID"}}),
Hi @Remco
adjust the first step like so:
#"Merged Queries" = Table.NestedJoin(#"Renamed Columns", {"Shipment Number"}, Table.Distinct(BKM_UPS_D2L_carton_details_lookup, {"TrackingID"), {"TrackingID"}, "BKM_UPS_D2L_carton_details_lookup", JoinKind.LeftOuter),
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Query editor error says that it is missing a comma, but all comma's are at the right place in your query. But I also found out that my data is to 'dirty' voor Distinct. I have to dive deeper in the data of the second table.
Or is there an other solution to fetch only the first matching record of the right table?
Yes, you can use the "Aggregate"-tab instead of the "Expand"-tab, choose any of the defualt actions and replace the function by "List.First".
Table.AggregateTableColumn(#"Grouped Rows", "Count", {{"Case", List.Count, "Count of Case"}})
will become
Table.AggregateTableColumn(#"Grouped Rows", "Count", {{"Case", List.First, "Count of Case"}})
But performance might be a pain: https://www.thebiccountant.com/2019/10/28/performance-tip-for-aggregations-after-joins-in-power-quer...
Better just to reference the lookup table then, do the distinct manually and uncheck "load to data model" if you're going to use that table just for this purpose.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
15 | |
15 | |
13 | |
12 | |
11 |