cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sajarac
Level 8

linking two tables

Hi there, I have this silly question but I cannot figure out:

I have two tables in my MS Access database:

1. Main Table

2. Projects

 

Projects and main table are linked by AssetID

 

I have a Papp with all of the information for my main table, but I would like to include a new screen that show my projects based on the selected value in my gallery1.

 

BTW, my data is exported into an excel file, the file is in my one drive, and the excel file has two tabs, one for the main "TblMaan" and one for projects "TblProjects"

 

Can someone point me in the right direction?

 

Thanks in advance

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
sajarac
Level 8

Re: linking two tables

Good News, finally it works!!!!

 

using this formula:

 

SortByColumns((If(drpfy.Selected.Value="All FY",Search( MainQuery, Proper(TextSearchBox1.Text), "Assessment_Name","SRName","AssessorName"), Filter( Search( MainQuery, Proper(TextSearchBox1.Text), "Assessment_Name"), drpfy.Selected.Value=FiscalYear))),"Assessment_Name",If(SortDescending1,Ascending,Ascending))

 

I still receiving a warning but is working

 

Untitled.png

 

Thank you very much for your kind cooperation.

 

Regards

 

 

 

View solution in original post

45 REPLIES 45
Community Support Team
Community Support Team

Re: linking two tables

Hi @sajarac,

 

Basically you should do the following:

1. Add those two table into PowerApps,

2. create a collection for Projects table, (See example in this thread, If the lookup table has > 500 records

3. Use Lookup or filter function to filter the collection created for Projects.

For example:

Filter(collection, AssetID=Gallery.selected.AssetID)

 

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.
sajarac
Level 8

Re: linking two tables

Thank toy very much for your prompt reply, unfortunatelly now I am getting totally lost. The other guy say this:

 

Here is the best way to do what you want to do, assuming owners has 500 or fewer records:

  1. Have an initial screen in the app to welcome the user, with no functionality except a button to proceed
    This is so that you can cache any lookup tables, this improves performance tremendously
  2. Set the Disabled property of the button to be:
    IsEmpty('[Access].[Owners]')
    This is so that you give the PowerApp time to connect the data source

Q/ so this mean my two tables will be here? 

 

IsEmpty('[tblMain].[TblProjects]')

 

  1. Set the OnSelect property of the button to be:
    ClearCollect(CachedOwners, '[Access].[Owners]'); Navigate(MyFirstScreen, None)
    This is so that you cache the lookup data, may take a few seconds but it is worth it
ClearCollect(CachedOwners, '[TblAMin].[TblProjects]'); Navigate(MyFirstScreen, None)

What does it mean? CachedOwners?

 

 

  1. Then, anywhere you need to display the owner name, you can look up to the cached data instead of needing to call the server.  This is most effective in a gallery, where otherwise the server would be called for every line. For example a text box text property would be set to:
    LookUp(CachedOwners, ThisItem.OwnerLookupField, DisplayNameField)

 

 How this apply to mi sample?

 

I am a heavy user of Access Web Apps and with a few tricks PowerApps can do great things with AWA as a back-end.

Here are a few things you should keep in mind, which are true at the time of writing:

1) It is far more efficient to cache lookup tables locally with a collection

2) If the lookup table has > 500 records you can still cache it by using for example:

ClearCollect(CachedInstruments, Sort('[Access].[Instruments]', ID, Ascending));
UpdateContext({MaxID: Max(CachedInstruments, ID)});
If(CountRows(CachedInstruments)=500,
	Collect(CachedInstruments, Filter(Sort('[Access].[Instruments]', ID, Ascending), ID > MaxID))
;
UpdateContext({MaxID: Max(CachedInstruments, ID)});
If(CountRows(CachedInstruments)=1000,
	Collect(CachedInstruments, Filter(Sort('[Access].[Instruments]', ID, Ascending), ID > MaxID))
;
UpdateContext({MaxID: Max(CachedInstruments, ID)});
If(CountRows(CachedInstruments)=1500,
	Collect(CachedInstruments, Filter(Sort('[Access].[Instruments]', ID, Ascending), ID > MaxID))
)))

 

Yes my two tables has more than 500 records, so:

 

CachedInstruments will be my data file, [Access].[Instruments] my two tables? tblmain and tblprojects?

 

Sorry to be a pain, but I thought that this was easier.

 

Regards

Meneghino
Level 10

Re: linking two tables

Hi @sajarac

 

I am the "other guy"

 

Things have moved on a little bit since I wrote that post, but the principles are still valid.

The basic idea is that if you have performance issues due to the large size of your tables or your connection quality or the shaping that you do, then you can address this by caching you table data locally in a collection, so that shaping, manipulation and lookups execute almost instantaneaously instead of having to wait for a remote query to execute for every row.

I notice that you use Excel as the back-end (i.e. where you store your table data), so there may be performance issues.  But you should first try the simple approach and then cache if you need to.

 

The simple approach would be to have in your second screen a gallery with the following Items property, or something like it:

 

Filter(TblProjects, AssetID = Gallery1.Selected.ID)

The details will depend on the exact names of your columns and controls, as well as the relationship between the tables.

 

If this works but you have performance issues, then you can use the caching approach described in the post that @v-micsh-msft referred to.

sajarac
Level 8

Re: linking two tables

Thank you very much "the other guy" lol 

 

Thank you very much Meneghino for your prompt reply. unfortunately it didn't work, after that I am getting an empty table

Meneghino
Level 10

Re: linking two tables

Hi @sajarac

Is that because of syntax or delegation?

If the first, we need to fix it.  If the second, then we can use caching and other techniques.

To check if it is syntax, please choose values that would return something in the first 500 rows of your data, better if in the first 100.

sajarac
Level 8

Re: linking two tables

Hi, and thanks again for your prompt reply, I have checked and now aI can see the fisrt Records in my table.

 

Just FYI my "Main Table has 500+ records and my "tblprojects" has 748 records.

 

But just to confirm, yes I am able to see the firts records which are Fiscal Year 2012, but nothing for FY14,15,16m,17,18

 

and one more question.

 

how I can add a calculated field to sum those filtered records?

 

Capture.PNG

Meneghino
Level 10

Re: linking two tables

OK, then at least we know what the problem is.

When you say MS Access as a back-end, you mean an Access Web App?

If so, then we can resolve all your issues, although you are aware that AWA is being phased out, right?

 

Assuming we are talking about AWA, then you should see the first 500 records of your 748, so I am surprised that you have 500 projects for 2012 and 248 for the following 5 years.  Or maybe I misunderstand...

 

sajarac
Level 8

Re: linking two tables

Hi, no sorry.

 

My data is an access database, and qith a couple of querys I export my two tables to excel, then I copy and paste into my data file in my one drive for business.

 

My table main has 500+ records  "customers" and the table projects has 748 projects which is basically I have a single location per customer and sometimes customer has 2, 3 or even more locations.

 

So the total 500+ records are for the fiscal years from 2012 up to 2018.

 

And BTW what the mean AWA? sorry Man Frustrated

Meneghino
Level 10

Re: linking two tables

Don't worry about AWA (Access Web Apps), it was a great technology (Access in the Cloud) but it is being phased out by MS.

 

Unfortunately Excel as a data source is not currently delegable, so it means that only the first 500 records are queriable.

 

Would you consider migrating the data to SharePoint lists or even CDS?

Even better would be Azure SQL DB, and given your Access background it shoud be easy.  I now use Azure SQL DB and it is a cheap and great way to store data.

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,719)