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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
check1
Frequent Visitor

Field from one table not directly related to another table

I have 3 tables - Employee, Tickets, TimeEntry.

 

Relationships are:

  • Employee to Tickets - One to Many on EmployeeID field
  • Tickets to TimeEntry - One to Many on TicketID

The Employee and Tickets table both have the EmployeeID field.  The TimeEntry table has a field UserID.  A Ticket record has one assigned employee, but can contain many time entries from many employees.

 

I am trying to retrieve the EmployeeName (from the Employee table) based on the UserID field in the TimeEntry table.  There's no relationship between the Employee table and the TimeEntry table.  

My PowerBI is DirectQuery, not Import.  How would I to retrieve the potential many EmployeeName for the many TimeEntry associated to one Ticket?  

Thanks!

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @check1 ,

 

Try merging the query twice like this and then combining the text:

 

let
    Source = Table.NestedJoin(TimeEntry, {"Ticket ID"}, Tickets, {"Ticket ID"}, "Tickets", JoinKind.LeftOuter),
    #"Expanded Tickets" = Table.ExpandTableColumn(Source, "Tickets", {"Employee ID"}, {"Employee ID"}),
    #"Merged Queries" = Table.NestedJoin(#"Expanded Tickets", {"Employee ID"}, Employee, {"Employee ID"}, "Employee", JoinKind.LeftOuter),
    #"Expanded Employee" = Table.ExpandTableColumn(#"Merged Queries", "Employee", {"Employee Name"}, {"Employee Name"}),
    #"Grouped Rows" = Table.Group(#"Expanded Employee", {"UserID"}, {{"Employee Names", each Text.Combine( List.Distinct([Employee Name]),",")}})
in
    #"Grouped Rows"

 

vcgaomsft_1-1722824821343.png

Note that the storage mode of the table for the merge query is Import.

vcgaomsft_2-1722824917345.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

6 REPLIES 6
v-cgao-msft
Community Support
Community Support

Hi @check1 ,

 

Try merging the query twice like this and then combining the text:

 

let
    Source = Table.NestedJoin(TimeEntry, {"Ticket ID"}, Tickets, {"Ticket ID"}, "Tickets", JoinKind.LeftOuter),
    #"Expanded Tickets" = Table.ExpandTableColumn(Source, "Tickets", {"Employee ID"}, {"Employee ID"}),
    #"Merged Queries" = Table.NestedJoin(#"Expanded Tickets", {"Employee ID"}, Employee, {"Employee ID"}, "Employee", JoinKind.LeftOuter),
    #"Expanded Employee" = Table.ExpandTableColumn(#"Merged Queries", "Employee", {"Employee Name"}, {"Employee Name"}),
    #"Grouped Rows" = Table.Group(#"Expanded Employee", {"UserID"}, {{"Employee Names", each Text.Combine( List.Distinct([Employee Name]),",")}})
in
    #"Grouped Rows"

 

vcgaomsft_1-1722824821343.png

Note that the storage mode of the table for the merge query is Import.

vcgaomsft_2-1722824917345.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Thank you Gao.  I was able to create a merge that allowed me to pull the Employee Name.  I appreciate your help!

@v-cgao-msft this solution will give all the names of the original ticket creators for each user working on tickets. This not not how I understood the question, but if this is what is required, I would follow a similar approach.

check1
Frequent Visitor

check1_0-1722633454915.png

Thanks @PwerQueryKees.  Hope this give a little better explanation of what I'm trying to do.  A ticket is assigned to a primary employee.  However, the ticket can have many time entries from many different employees.  I am trying to find the name of those employees for those time entries.  I can show the UserIDs for each time entry, but I'm trying to resolve the name of the employee associated with that UserID, which is the EmployeeName from the Employee table.   If I link the TimeEntry and Employee table (using UserID and EmployeeID) it creates ambiguous paths.  

Ok. So the user id is not an employee id. What else have you got to connect a user to an employee? Is there a user table you can use? Is there another filed, like email address you can use?

You mention ambiguous results. What do you mean? Because I would assume it would produce erroneous results or no results at al if you match the user id with employee IDs.

If all of the above does not work, your question might me unsolvable...

PwerQueryKees
Responsive Resident
Responsive Resident

From your description, the only option is to start with the time entry column, the mergejoin the ticket table on the ticket I'd and the join the employee table on the employee id.

This will get you the name of the original employee assigned to the ticket.

I am not sure they is what you.

If you need further help give an example of your date and of your expected results.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors