cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Referencing data from one table from a selection in another

I have two SQL tables - '[dbo].[Person]' and '[dbo].[Department]'

In '[dbo].[Person]' there is a DepartmentID.  I want to reference the DepartmentID in '[dbo].[Department]' and return departmentName based on the selected item in '[dbo].[Person]'

 

I tried: 
LookUp('[dbo].[Department]', DepartmentID = '[dbo].[Person]'.Selected.DepartmentID, DepartmentName)
LookUp('[dbo].[Department]', DepartmentID = ThisItem.DepartmentID, DepartmentName)

LookUp('[dbo].[Department]', DepartmentID = DepartmentID, DepartmentName)

 

The third option is the only one that returns anything - and it returns the first DepartmentName in '[dbo].[Department]' for all records

 

1 ACCEPTED SOLUTION

Accepted Solutions

The way around this problem is to create a VIEW in SQL.  

 

Watch this video

View solution in original post

3 REPLIES 3
Community Support
Community Support

Hi @ChipMichael,

 

Are you using this formula in the Items property of the Gallery control? If so, please unserstand that one Gallery could only have one data source. To use the DepartmentID from '[dbo].[Person]', you need to first insert a dropdown control, set its Items property to:

Distinct( '[dbo].[Person]',DepartmentID)

Then set the Items property of the Gallery to:

Filter('[dbo].[Department]', DepartmentID = Dropdown1.Selected.Value)

To return the DepartmentName, with the Gallery control selected, click on the table name is the right side, then pick with field you want to show in the Gallery:

Capture.PNG

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Would it be possible to put table A in a list - reference the "selection" from that list based on a selection from table B? 

 

i.e., 

Table A 

PersonID   Name   DepartmentID      TitleID
     1             Jack         2                          3
     2             Jill            1                          2

 

Table B 

DepartmentID    DepartmentName

       1                     Marketing

       2                     Manufacturing

 

Table C 

TitleID          Title

  1               President
  2               Vice President
  3               Director

If I want information from PersonID 1 from Table A how do I display ?

Jack, Manufacturing, Director   

The way around this problem is to create a VIEW in SQL.  

 

Watch this video

View solution in original post

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (22,893)