cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TiredOldCoder
Level: Powered On

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
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
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.

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
TiredOldCoder
Level: Powered On

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!

Super User
Super User

Re: Filtering with lookup fields in PowerApps

Happy to help out!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,574)