web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / 'With' Function and fi...
Power Apps
Answered

'With' Function and filtered collection not allowing access to choice column value

(0) ShareShare
ReportReport
Posted on by 5,836 Moderator

I am using the With function to use the data from a filtered collection in creating another collection.   It is not allowing me to properly access the value of a choice column.   Value should be the correct next step but it doesn't like it at all.   ITContacts is a collection in the app.

 

withfunctionerror.jpg

 

withfunctionerror2.jpg

 

 

withfunctionerror3.jpg

 

 

With(
 {wFilterContacts:
 Filter(ITContacts, Email = ThisItem.PrimaryContact)
},

 ClearCollect(Primary,
 {
 Number: wFilterContacts.WorkPhone,
 Type: "BP",
 SortOrder:
 If(
 wFilterContacts.PrimaryAfterHoursPhone = "Business Phone", 1,
 wFilterContacts.PrimaryAfterHoursPhone = "Mobile Phone", 2,
 3
 )
 },

 {
 Number: wFilterContacts.CellPhone,
 Type: "MP",
 SortOrder:
 If(
 wFilterContacts.PrimaryAfterHoursPhone = "Mobile Phone", 1,
 2
 )
 },
 
 {
 Number: wFilterContacts.HomePhone,
 Type: "HP",
 SortOrder:
 If(
 wFilterContacts.PrimaryAfterHoursPhone = "Home Phone", 1,
 wFilterContacts.PrimaryAfterHoursPhone = "Other Phone", 4,
 3
 )
 },

 {
 Number: wFilterContacts.Other_x0020_Phone,
 Type: "OP",
 SortOrder:
 If(
 wFilterContacts.PrimaryAfterHoursPhone = "Other Phone", 1,
 4
 )
 }
 )
)

 

 

Categories:
I have the same question (0)
  • Verified answer
    JamesYumnam Profile Picture
    on at

    Hi @JR-BejeweledOne ,

    Please try using LookUp function to get your record instead of Filter.

     

    Reason: As per my understanding, With function works with a single record. so it should work on a single record returned by LookUp function. You have used Filter function which returns a table. Hence, you are seeing the Incompatible types error.

    LookUp function will return a single record based on your condition.

     

    Hope this helps.

  • RusselThomas Profile Picture
    4,014 on at

    Hi @JR-BejeweledOne ,

    A filter comparitor automatically unpacks each row field to do the comparison, so you can have something like;

    Filter(source, column="bob")

    but you can't have something like

    If(source.column="bob")

    just by itself, because there's nothing processing any rows - it's just trying to compare a table to a string which is why you're seeing the error.

    You might need to try wrapping it in something that would process each row and then do the comparison, that should give you access to the fields on a per-row basis - something like a ForAll or an AddColumns might work in this instance depending on exactly how you want your Primary collection to look I guess.

    eg:

    ForAll(Filter(ITContacts, Email = ThisItem.PrimaryContact) As wFilterContacts,
    Collect(Primary,{
     Number: wFilterContacts.WorkPhone,
     Type: "BP"
     SortOrder: If(wFilterContacts.PrimaryAfter.....

     If processing it row by row doesn't give you the format you're looking for, perhaps you can post an example of the source table and the destination table and we can figure it out from there?

    Hope this helps,

    RT

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 413

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
timl Profile Picture

timl 315 Super User 2026 Season 1

Last 30 days Overall leaderboard