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

Displaying related data

This is a very basic question so please bear with me, I have about 4 hours of experience with PowerApps so far.

 

I've created a basic app that displays inventory data from an on prem SQL DB.

 

The first screen is a gallery that displays items in our inventory table (i.e. 1 asset = 1 record in table).

 

When someone taps on an asset, it takes them to a detail screen which shows more of the properties of that asset from the same table.

 

There is a related inventory_comments table for comments related to particular assets, and that is a many to one relationship (i.e. 1 asset might have multiple comments).  I want to display all of the comments associated with the currently selected asset.  The two tables are linked with an ID column (i.e. asset record in inventory table and comment records in comments table would each have the same ID.

 

What is the best way to accomplish this?

 

Screenshot to give a visual representation of what I'm trying to do.

12 REPLIES 12
cds
Impactful Individual
Impactful Individual

insert a gallery
Items: Sort(Filter(Inventory_Comments, ItemGallery.Selected.ID = CommentID), Created, Descending/Ascending)

 

Use a LookUp

LookUp(Table2,ID=ThisItem.ID,Comment column)

 

Table 2 represent the table with the comments Column

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

FredW
Frequent Visitor

Thanks!  That seems to work from a syntax perspective, but for some reason the table isn't displaying any data.  I know that BrowseGallery1.Selected.ID contains the correct asset ID, and I know the table has entries where ID equals that value.

 

I feel close but can't seem to figure out why no data is displaying.  Any thoughts?

 

image.png

cds
Impactful Individual
Impactful Individual

The ID wont match ID

you need to match BrowseGalleryID to relationship column in Comment database... ParentID?

FredW
Frequent Visitor

I see what you mean but it should match the ID column.  There are two ID fields in the comments table, CommentID which is just a unique ID and ID which is the asset ID (3093 in this example).

 

image.png

cds
Impactful Individual
Impactful Individual

Are you resetting the gallery on screen change/losing scope to the BrowseGallery?

 

maybe try set(SelectedItem, ThisItem) onselect in browsegallery

 

and change browsegallery.selected.id to selecteditem.id

FredW
Frequent Visitor

I'm not sure about focus, but I did create a label elsewhere on the page with the value set to BrowseGallery1.Selected.ID and verified that the value returned 3093 as expected, so I'd assume the value of that property would be constant across any objects on the page referencing it?

 

I also tried simply omitting the filter and setting the value of the data table to '[dbo].[Inventory_Comments]' thinking that might show me the first records in the table, but I still got nothing.  Not sure if that's expected behavior or not.

As you have shown the comments table can you show the other table

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

FredW
Frequent Visitor

Sure here you go:

 

CREATE TABLE [dbo].[Comments](
[CommentID] [int] IDENTITY(1,1) NOT NULL,
[ID] [int] NOT NULL,
[DateStamp] [datetime] NOT NULL,
[Comment] [varchar](500) NOT NULL,
[username] [varchar](50) NULL
)

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,097)