web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Displaying related data
Power Apps
Unanswered

Displaying related data

(0) ShareShare
ReportReport
Posted on by 21

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.

Categories:
  • cds Profile Picture
    1,001 on at

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

     

  • eka24 Profile Picture
    20,925 on at

    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 Profile Picture
    21 on at

    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 Profile Picture
    1,001 on at

    The ID wont match ID

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

  • FredW Profile Picture
    21 on at

    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 Profile Picture
    1,001 on at

    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 Profile Picture
    21 on at

    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.

  • eka24 Profile Picture
    20,925 on at

    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 Profile Picture
    21 on at

    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
    )

  • eka24 Profile Picture
    20,925 on at

    I was asking for the other table since you have already shown the comments 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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard