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

Filter gallery through multiple entities

I have three entities in the CDS with the following fields:

-Assessment: AssessmentID (primary key), AssessmentName

-AssessmentQuestions: AssessmentQuestionID (primary key), AssessmentID (lookup to Assessment), QuestionTextID (lookup to QuestionText)

-QuestionText: QuestionTextID (primary key), QuestionText

 

There are two galleries: one for Assessment and QuestionText.

 

What I am trying to do is to have the Assessment gallery display across the top and the QuestionText gallery down the side. As the user selects different options in the Assessment gallery, the questions in the QuestionText gallery will be filtered.

 

I am having trouble figuring out a way to get the QuestionText gallery to filter. The QuestionText gallery does not necessarily need to read directly from the QuestionText entity. I have not as of yet had luck using the AddColumn/LookUp process to get the second gallery (QuestionText) to show the necessary data.

 

Any help or advice? Thanks! 

3 REPLIES 3
TimRohr
Solution Sage
Solution Sage

Provided you have the Relationships established between your entities, then if the user selects an assessment from the Assessment gallery, the Question gallery should be able to filter its Items. The Data should be set to AssessmentQuestions, and the Items property to:

Filter(AssessmentQuestions,AssessmentID=Assessment_BrowseGallery.Selected.AssessmentID)

Then, on each entry in that gallery, you would have a label to pull in the Question text... this *should* work, but I've had trouble with this formation recently (see the next option for a workaround):

ThisItem.QuestionTextID.QuestionText

If the above doesn't work, use a LookUp() in the Text property of the label:

Lookup(QuestionText, QuestionTextID=ThisItem.QuestionTextID,QuestionText)

If neither of the above options work, make sure you have your Relationships properly defined in CDS.

 

HTH

Hey Tim,

 

Thank you for your help. What you suggested did not work. I am unsure if PowerApps allows filtering based on reference fields in a Canvas App. 

 

I was able to get around the need of filtering using information I found in the below article:

https://powerapps.microsoft.com/en-us/blog/one-to-many-relationships-for-canvas-apps/

 

I'm glad you got something workable, but I thought I would just add:

 

If by "reference fields" you mean the lookup field creating the relationship between your 2 entities, then... yes, you should be able to filter based on that. For instance, if you have many questions associated with one assessment, you should be able to pick the assessment in one part of your app, then filter the Questions datasource to be only where the Assessment field (a lookup to the Assessment entity) is the Assessment you have chosen.

 

If you want to explore it more, post a bit more of your data and we can work it out.

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!

Users online (4,976)