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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / LookUp in Filter retur...
Power Apps
Answered

LookUp in Filter returns wrong values

(0) ShareShare
ReportReport
Posted on by 329

Hi,

 

I'm using a PowerApps EditForm and added a custom card.

In here i put a ListBox that checks a different list for ID-Numbers and retrieves values of a different column.

I have 3 columns in here; ProjectLeader, Employee, and HoursInProject.

code:

Filter(
 'Medewerkers Verbeterprojecten Operations',
 LookUp(
 'Medewerkers Verbeterprojecten Operations',
 ProjectID = Gallery1.Selected.ID,
 Projectleider
 )
)

 

The formula is going to check which SharePoint ListItems match the Gallery1.Selected.ID and return that ProjectLeader.

 

The strange thing is, is that i'm getting the employees back (different column) that match the Gallery1.Selected.ID.

No matter what i want the result of the LookUp to be, it still give me the matching employees instead of the projectleader.

Same happens when i want the 'HoursInPRoject' as a result of the LookUp.

 

Any idea how to tackle this? 

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    The Syntax for Filter is 

    Filter( Table, Formula1 [, Formula2, ... ] )

    The third parameter you are specifying is being evaluated to see if the record should be in the filtered data source.  It doesn't control which columns are returned. So your filter is basically asking for all the records where the ProjectID matches the selected ID and where the ProjectLeader column exists.

     

    Depending on the control in the custom card you should be able to select which field from the filtered data source is being shown.  You can't do that in the filter statement itself.

  • v-yutliu-msft Profile Picture
    on at

    Hi @PVosEska ,

    Could you describe more clearly about what do you want to filter based on and what value do you want to get?

    The right syntax of Filter should be like:

    Filter(tablename, formula1[,formula2,formula3,....])   

    //for example  Filter(tablename, field1=value1,field2=value2)

    This formula will return a table. (the records that meet the formulas)

     

    The right syntax of LookUp function should be like:

    LookUp(tablename,formula[,fieldname])

    //For examplr: LookUp(tablename, field1=value1,field2)

    If you just not use fieldname in the formula, you will get one record that meet the requirement

    If you use fieldname in the formula, you will get one value( the field value of that record)

     

    So the formula that you use:

     LookUp(
     'Medewerkers Verbeterprojecten Operations',
     ProjectID = Gallery1.Selected.ID,
     Projectleider
     )

    This will return one record's Projectleider value.

    So you could see your formula as:

    Filter(
     'Medewerkers Verbeterprojecten Operations',
     value //This is not a formula, you need to use formula like: field=value
    )

    Here is a doc  about these two functions for your reference:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-filter-lookup

     

     

     

    Best regards,

     

  • PVosEska Profile Picture
    329 on at

    Hi @v-yutliu-msft ,

     

    I am trying to get a list of employees with the same ID from a second SharePoint list.

     

    I do this by:

    - Creating two lists, one for the project, one for the employees and projectleader of that project

    - Creating the App, inserting an EditForm,

    - Collecting the LastSubmit.ID on 'SubmitForm'

    - let users put in the relevant employees for that project

    - Patch it to a second list, with the ProjectID the same as the LastSubmit.ID.

     

    I need a combination of the filter() and LookUp() as i can't choose what i want the result to be with the filter, but can't collect more than 1 item with a LookUp().

  • PVosEska Profile Picture
    329 on at

    Hi @Pstork1,

     

    Unless i read it wrong, i don't think that is correct.

     

    My Formula basically consists of: Filter(<DataSource>,LookUp(<DataSource>,Condition,result))

    So i'm just using the LookUp as the second parameter of the filter, i am not using a 3rd Param.

  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    Sorry, I misread your code.  But even if you reduce to a single column it still returns it in the form of a record not a text value.  So you need to add the property to your card to get the specific value out of the object.

  • Verified answer
    PVosEska Profile Picture
    329 on at

    @Pstork1 ,

     

    Okay, i did found out though that i can also use a .Value after the filter, and that was exactly what i needed. so it boils down to: 'Filter(<DataSource>,Condition).Value'  

     

    Where .Value is de column that you want to show. In my case, this was ProjectLeader or Employee

     

    WHY DID I NOT KNIOW THIS! thanks though!

  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    As I mentioned in my previous reply.  The Lookup is returning a record, which is an object.  You have to specify which property you want to display.  That is the 'value' name you are adding.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard