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

Opposite of filter in Power Query (ONLY MATCHING RECORDS AND OTHER RECORDS NEEDS TO KEEP)

Hello Community,
I am looking for help for the below scenarios; I want to achieve in Power Query.
I want to keep or remove rows based on the "Lookup Table." values.
***Requirements
If the lookup table's "fiscal product" column value is available in any of the three tables, I want to keep that value. Otherwise, I want to filter out nonmatching values from tables.

communityfinal123.PNG


1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Did you know that you can merge on multiple columns?  Do a left anti join between your fact tables and the reference table based on all original key columns.

 

Fact table:
Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlHSUUpUitWBsJLALFO4mClELBYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [year = _t, product = _t])

Exclusion table:
Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlXSUUpUio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [year = _t, product = _t])

Result table:
Table.NestedJoin(Fact, {"year", "product"}, Exclusion, {"year", "product"}, "Exclusion", JoinKind.LeftAnti)

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

Did you know that you can merge on multiple columns?  Do a left anti join between your fact tables and the reference table based on all original key columns.

 

Fact table:
Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlHSUUpUitWBsJLALFO4mClELBYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [year = _t, product = _t])

Exclusion table:
Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlXSUUpUio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [year = _t, product = _t])

Result table:
Table.NestedJoin(Fact, {"year", "product"}, Exclusion, {"year", "product"}, "Exclusion", JoinKind.LeftAnti)
lbendlin
Super User
Super User

please state your question again, "i want to filter out nonmatching values from tables" is not clear.

Thank you so much for attending to my questions @lbendlin 
[please state your question again, "I want to filter out nonmatching values from tables" is not clear.]
Sunday_EST.png
***If values match the lookup table "final product" column; then I want to keep that row—otherwise, I want to filter out that rows.Example: If Fiscal 04, I want to filter(remove that rows) the final product value (5-ABC), but if Fiscal 05, then (5-ABC) should stay.Let me know if you need more information.

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.