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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Marek12345
Frequent Visitor

Create new table in Power Query with data that meet certain conditions from other tables

Hi, 

 

I have decided to move my topic to the Power Query section to seek your further help.

 

https://community.fabric.microsoft.com/t5/Power-Query/Filter-data-that-match-all-conditions-in-other...

 

I've put the power BI example here: https://dropmeafile.com/#559874d471

 

I have 2 tables which are not connected to each other:

- Table with Users and Conditions they meet 

- Criteria with different sets of values; they define, when certain criteria is met  - all of values need to be met to create a certain criterium

 

I need to make a calculation in power query which will search for all those sets of values through all users and create a table listing out the users with all criterias they meet. I will show this static table in power BI. 

I have so much data that I cannot due it with a measure - takes to long to refresh because it recalculates all the time. 

 

Thanks for support,

Marek

 

 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

DAX Table:wdx223_Daniel_0-1711073010145.png

M Query:

wdx223_Daniel_1-1711073370186.png

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Marek12345 

You can create refer to the following queries.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wci7KLEktykxUMFTSUXKGkkZg0hRMminF6iApM8JQZgxVjKLMGEOZOZBEVWOCpMYYaheItFCKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Criteria = _t, #"Column 1" = _t, #"Column 2" = _t, #"Column 3" = _t, #"Column 4" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Criteria", type text}, {"Column 1", type text}, {"Column 2", type text}, {"Column 3", type text}, {"Column 4", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Criteria"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each [Value] <> null and [Value] <> ""),
    #"Added Custom" = Table.AddColumn(#"Filtered Rows", "Custom", each Text.Combine(Table.SelectRows(#"Filtered Rows",(x)=>x[Criteria]=[Criteria])[Value],",")),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Attribute", "Value"}),
    #"Removed Duplicates" = Table.Distinct(#"Removed Columns"),
    #"Added Custom1" = Table.AddColumn(#"Removed Duplicates", "Custom.1", each 1)
in
    #"Added Custom1"
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi1OLVIwVNJRcgaSsTooAkboAsboAiboAqboAmYIASN0W4zQbTFCN8MI3QxjdGtN0A01QTfUBN3pJuiGQgQslGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Users = _t, Conditions = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Users", type text}, {"Conditions", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each 1),
    #"Merged Queries" = Table.NestedJoin(#"Added Custom", {"Custom"}, Query2, {"Custom.1"}, "Query2", JoinKind.LeftOuter),
    #"Expanded Query2" = Table.ExpandTableColumn(#"Merged Queries", "Query2", {"Criteria", "Custom"}, {"Criteria", "Custom.1"}),
    #"Added Custom1" = Table.AddColumn(#"Expanded Query2", "Custom.2", each let a=Text.Split([Custom.1],","),
 b=List.Count(a),
 c=List.Distinct(Table.SelectRows(#"Expanded Query2",(x)=>x[Users]=[Users])[Conditions]),
 d=List.Count(List.Intersect({a,c}))
 in if b=d then "Yes" else "No"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Conditions", "Custom", "Custom.1"}),
    #"Removed Duplicates" = Table.Distinct(#"Removed Columns"),
    #"Pivoted Column" = Table.Pivot(#"Removed Duplicates", List.Distinct(#"Removed Duplicates"[Criteria]), "Criteria", "Custom.2")
in
    #"Pivoted Column"

Output

vxinruzhumsft_0-1711074384244.png

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

wdx223_Daniel
Super User
Super User

DAX Table:wdx223_Daniel_0-1711073010145.png

M Query:

wdx223_Daniel_1-1711073370186.png

 

Hi, this works like a charm! Thank you!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors