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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
sacred_hoops
New Member

Filtering problem on combined data

Hello - I have a problem with the way my data exists that doesn't allow me to filter what I want. I suspect this problem has been enocuntered before, but my normal soultion of Googling the problem isn't working as I don't quite know how to phrase what the problem is!

I'll try my best to explain....

Here is an example simplifed version of my data. The two tables have a one-to-many relationship that allows me to filter on the staff 

 

Job Table A

Job #locationStaff
1LondonSteve
1LondonEngineer
2New YorkPablo
2New YorkEngineer
3ParisTim
3ParisEngineer
4MadridSteve
5GlasgowTim
6MiamiPablo

 

Reference Table B (Unique values)

NameType ID
Steve2
Tim2
Pablo2
Engineer240

 

As you can see, In the Job table I have jobs with staff & 'Engineer' assigned (Jobs 1,2.3), and jobs with only staff assigned (4,5,6). 

What I want to achieve, is to filter on jobs with an 'Engineer' assigned, and return the list of jobs (1,2,3) with the staff (Steve, Tim, 

 

In it's current relationship, by filtering on 'Engineer' I lose the records of the staff from the job table.

 

What is the best way to model my data to achieve this?

 

In the reference table I have a type ID that distinguishes between staff as they have a different Type ID if that can be used. 

 

Thank you in advance for any support you can offer.

Thanks, 

Tom

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @sacred_hoops ,

 

You can group your jobs into nested tables then evaluate for the presence of "Engineer" over each table, something like this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfLJz0vJzwMygktSy1KVYnXQhF3z0jPzUlOLwDJGQAG/1HKFyPyibCAzIDEpJx+bBIomY7DKosxiIB2SmYshhqLYBCjgm5hSlJmC4iRTIM89J7E4Pb8cyRQzkOLMxNxMhFtiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [JobNumber = _t, location = _t, Staff = _t]),
    chgTypes = Table.TransformColumnTypes(Source,{{"JobNumber", Int64.Type}, {"location", type text}, {"Staff", type text}}),
    groupJobNumber = Table.Group(chgTypes, {"JobNumber"}, {{"data", each _, type table [JobNumber=nullable number, location=nullable text, Staff=nullable text]}}),
    addHasEngineer = Table.AddColumn(groupJobNumber, "hasEngineer", each if List.Contains([data][Staff], "Engineer") then "hasEngineer" else null),
    expandDataCol = Table.ExpandTableColumn(addHasEngineer, "data", {"location", "Staff"}, {"location", "Staff"})
in
    expandDataCol

 

Example query output:

BA_Pete_0-1671035687838.png

 

This can easily be expanded to create a more generic flag for identifying group members other than "Engineer".

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

1 REPLY 1
BA_Pete
Super User
Super User

Hi @sacred_hoops ,

 

You can group your jobs into nested tables then evaluate for the presence of "Engineer" over each table, something like this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfLJz0vJzwMygktSy1KVYnXQhF3z0jPzUlOLwDJGQAG/1HKFyPyibCAzIDEpJx+bBIomY7DKosxiIB2SmYshhqLYBCjgm5hSlJmC4iRTIM89J7E4Pb8cyRQzkOLMxNxMhFtiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [JobNumber = _t, location = _t, Staff = _t]),
    chgTypes = Table.TransformColumnTypes(Source,{{"JobNumber", Int64.Type}, {"location", type text}, {"Staff", type text}}),
    groupJobNumber = Table.Group(chgTypes, {"JobNumber"}, {{"data", each _, type table [JobNumber=nullable number, location=nullable text, Staff=nullable text]}}),
    addHasEngineer = Table.AddColumn(groupJobNumber, "hasEngineer", each if List.Contains([data][Staff], "Engineer") then "hasEngineer" else null),
    expandDataCol = Table.ExpandTableColumn(addHasEngineer, "data", {"location", "Staff"}, {"location", "Staff"})
in
    expandDataCol

 

Example query output:

BA_Pete_0-1671035687838.png

 

This can easily be expanded to create a more generic flag for identifying group members other than "Engineer".

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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