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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

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
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.