cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
texansfan09
Level: Powered On

Power App - SQL Primary Table & Lookup Tables - How to create App?

I have my primary SQL table setup using i'ds for all of the related lookup data and a few additional fields for data entry.

 

My question is that when I go to create the app, how do I bring in the lookup tables and have the text data display for the lookups?

 

It was easy to create using a SharePoint list, however this is a new scenario for me.

 

TablesTable NamesType
Contractorstbl_Scaf_ContractorsLookup
Shiftstbl_Scaf_ShiftsLookup
Tag Colorstbl_Scaf_Tag_ColorsLookup
Inspectionstbl_Scaf_InspectionsPrimary
Resultstbl_Scaf_ResultsLookup
Inspectortbl_Scaf_InspectorLookup
Projecttbl_Scaf_ProjectLookup

 

Primary Table:

 

FieldsType

ProjectIDInteger
ContractorIDInteger
InspectorIDInteger
ShiftIDInteger
TagColorIDInteger
Tag#Text
ResultInteger
NotesText
5 REPLIES 5
Community Support Team
Community Support Team

Re: Power App - SQL Primary Table & Lookup Tables - How to create App?

Lookup table under SQL Table is a little different from that in SharePoint list.

 

TO have the proper ID displayed with the proper field, we need first add the corresponding Table into PowerApps, then use the lookup() funciton to map the ID, and choose the field to display.

 

For example:

 

Within the Primary Table Gallery, for the Label to show the Contractors name, the formula should be:

Lookup (Contractors, ID=ThisItem.ContactID, ContractorNameField)

Meneghino has a good explaination on this part in the following thread:

Lookup on SQL Server

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Meneghino
Level 10

Re: Power App - SQL Primary Table & Lookup Tables - How to create App?

In addition, now that we have the possibility of adding views to PowerApps, this might a better solution for some scenarios.

 

Just create the view that you like with the text and connect to it from PowerApps

texansfan09
Level: Powered On

Re: Power App - SQL Primary Table & Lookup Tables - How to create App?

Thank you for your assistance.  So your information was very helpful in creating a lookup.  Now my next follow up question.

 

 

 

I have these tables:

 

Tables

Table Names

Type

Contractors

tbl_Scaf_Contractors

Lookup

Shifts

tbl_Scaf_Shifts

Lookup

Tag Colors

tbl_Scaf_Tag_Colors

Lookup

Inspections

tbl_Scaf_Inspections

Primary

Results

tbl_Scaf_Results

Lookup

Inspector

tbl_Scaf_Inspector

Lookup

Project

tbl_Scaf_Project

Lookup

 

 

This is the primary table fields.

 

FieldsType

ProjectID

Integer

ContractorID

Integer

InspectorID

Integer

ShiftID

Integer

TagColorID

Integer

Tag#

Text

Result

Integer

Notes

Text

 

When you create a connection, initially you are only allowed to select one data souce.  (Which I did, the primary (Inspections).  Then once the app is created, I added the additional lookup tables.  By default Power Apps build the app around the primary table that has all of the ID columns.

 

The default view is just a text field that only allows numbers (ID's).  If I update with the lookup statement, I get a list of the data but it does not update the primary table.

 

I created the SQL tables to be future proof and based upon ID's in case the text data was to change in the future.

 

So my form should display the "text" (User Friendly data), and when selected / updated - update the SQL primary table while being limited to only the lookup table data for the lookup fields.

 

How do I change the text (ID) field to not only display the text (user friendly data), but also to upadate the primary table with the appropriate ID's?

 

Any help would be greatly appreciated.

texansfan09
Level: Powered On

Re: Power App - SQL Primary Table & Lookup Tables - How to create App?

I tried that, however it only allows a view only scenario.  I am trying to create a data entry app, that collects data and updates an SQL database.  Thanks for the idea.

Meneghino
Level 10

Re: Power App - SQL Primary Table & Lookup Tables - How to create App?

From your comment I gather that you are building an app from data as opposed to a blank canvas app?

In my experience it is much easier in the end to build a blank canvas app and avoid the use of forms, just build the forms you need from the individual controls.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 212 members 4,822 guests
Please welcome our newest community members: