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.
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.
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?
The ID wont match ID
you need to match BrowseGalleryID to relationship column in Comment database... ParentID?
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).
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
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.
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
)
User | Count |
---|---|
257 | |
108 | |
90 | |
51 | |
44 |