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

Incompatible data type for comparison error when applying a filter from a dropdown box to a Gallery

I am trying to filter a Gallery from a dropdown box in PowerApps.  The Gallery data resides in a SharePoint list called 'Contractor Database', and the column I'm trying to filter on is a lookup column called Dept.  The items in this column are pulled from another SharePoint List called Departments.  I have a DropDown list called  DepartmentFilterBox that lists all the different departments.  I have been able to create this dropdown list from two different methods:  Sort(Departments, Title), which pulls the values from the Departments SharePoint List or Distinct(Choices('Contractor Database'.Dept), Value) which pulls the Distinct values from the 'Contractor Database' SharePoint List.   (I was leaning towards the first solution as I didn't have the delegation issue and it just seemed cleaner)

 

When I try to filter on this result, I'm getting an error for "Incompatible Types for Comparison"  (Either comparing a record to a record, or a record to text).   This is my formula for Items in the Gallery:

Filter('Contractor Database', Dept = DepartmentFilterBox.Selected.Result)

 

Any help on where I'm going wrong?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@remariu 

If Dept is a lookup column as you seem to indicate, then lookup columns are records that contain two columns, an Id and a Value.   The Id column will contain the ID of the record in the looked up list and the Value will contain the value of the column that is chosen in the settings to be the column referenced (default is Title).

So, if the Deptarment name is in the title, then your formula should be:

   Filter('Contractor Database', Dept.Value = DepartmentFilterBox.Selected.Result)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
neuronic
Helper I
Helper I

Hi, I am not sure why is failing. However, with analogous set-up I don't have a problem although perhaps try for the dropdown:

Distinct('Contractor Database',Dept )

RandyHayes
Super User
Super User

@remariu 

If Dept is a lookup column as you seem to indicate, then lookup columns are records that contain two columns, an Id and a Value.   The Id column will contain the ID of the record in the looked up list and the Value will contain the value of the column that is chosen in the settings to be the column referenced (default is Title).

So, if the Deptarment name is in the title, then your formula should be:

   Filter('Contractor Database', Dept.Value = DepartmentFilterBox.Selected.Result)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,844)