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
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (5,362)