cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Filtering with lookup fields in PowerApps

I have three lists:

Student: ID, Title

Class: ID, Title

AssignedClass: ID, Title,  StudentName[lookup Student.Title],  ClassName[lookup Class.Title]

Task: create set of Class items that the Student is NOT assigned, for a specific student

I cannot for the life of me get this to work. Below is a sample of one attempt

Filter(Class, Not(Title in Filter(
        'AssignedClass',
        StudentName.Value = "Bob"
     ).ClassName)
)

Errors indicate String cannot be compared to a Record. Any thoughts?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Filtering with lookup fields in PowerApps

So, unable to let this go Smiley Very Happy I made a simple mock-up of your data and a simple app to view it in. One way I accomplished what you are after is I made a dropdown to select students. In the OnChange section of the dropdown I put:

Clear(NotAssignedClass);
ForAll(
    Class,
    If(
        IsBlank(LookUp(AssignedClass, StudentName = Dropdown1.Selected.Title && ClassName = Class[@Title])),
        Collect(
            NotAssignedClass,
            {ID: Class[@ID], Title: Class[@Title]}
        )
    )
)

This creates a collection called NotAssignedClass which is a list of all classes the student selected in the dropdown is not in, according to the AssignedClass data.

 

Feel free to let me know if this helps or needs further adjustment/explaination.

View solution in original post

4 REPLIES 4
Highlighted
Super User
Super User

Re: Filtering with lookup fields in PowerApps

Off the top of my head, I think the error is coming from this part:

StudentName.Value = "Bob"

StudentName.Value is a record whereas "Bob" is a string. Maybe try:

StudentName = "Bob"

If that doesn't do the trick, let me know and I'd be happy to help further.

Highlighted
Super User
Super User

Re: Filtering with lookup fields in PowerApps

So, unable to let this go Smiley Very Happy I made a simple mock-up of your data and a simple app to view it in. One way I accomplished what you are after is I made a dropdown to select students. In the OnChange section of the dropdown I put:

Clear(NotAssignedClass);
ForAll(
    Class,
    If(
        IsBlank(LookUp(AssignedClass, StudentName = Dropdown1.Selected.Title && ClassName = Class[@Title])),
        Collect(
            NotAssignedClass,
            {ID: Class[@ID], Title: Class[@Title]}
        )
    )
)

This creates a collection called NotAssignedClass which is a list of all classes the student selected in the dropdown is not in, according to the AssignedClass data.

 

Feel free to let me know if this helps or needs further adjustment/explaination.

View solution in original post

Highlighted
Helper I
Helper I

Re: Filtering with lookup fields in PowerApps

I had to make a few tweaks, but yes - @wyotim YOU NAILED IT!

 

Clear(NotAssignedClass);
ForAll(
    Class,
    If(
        IsBlank(LookUp(AssignedClass, StudentName.Value = Dropdown1.Selected.Title && ClassName.Value = Class[@Title])),
        Collect(
            NotAssignedClass,
            {ID: Class[@ID], Title: Class[@Title]}
        )
    )
)

 

Thank you so much!

Highlighted
Super User
Super User

Re: Filtering with lookup fields in PowerApps

Happy to help out!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (4,254)