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 / Filter and addColumn t...
Power Apps
Answered

Filter and addColumn to same gallery

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I'm trying to show a gallery with filtered data and add a new column from a second datasource, but I'm not able to get the two expressions to work together. I'm able to get them to work separatly.

 

Any suggestions?

 

Gallery.item = Filter(Table1,FieldB="003") ;AddColumns(Table1,"Name",LookUp(Table2,PersonnelNumber=Table1[@FieldA],Name))

Categories:
  • Brian Dang Profile Picture
    3,976 on at

    Hi @Anonymous,

     

    AddColumns takes a table as its first argument. And a Filter on a table is still a table.

     

    So you can place the filter as the first argument in AddColumns:

     

    AddColumns(Filter(Table1,FieldB="003"),"Name",LookUp(Table2,PersonnelNumber=Table1[@FieldA],Name))

    Let me know if this helps.

     

    Brian

  • Verified answer
    Mike8 Profile Picture
    1,330 on at

    Hello,

    How about this..
    Gallery.item = AddColumns(Filter(Table1,FieldB="003") ,"Name",LookUp(Table2,PersonnelNumber=Table1[@FieldA],Name))

    or this..
    Gallery.item= Filter(AddColumns(Table1,"Name",LookUp(Table2,PersonnelNumber=Table1[@FieldA],Name)),FieldB="003") 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for the feedback, This worked:

    Gallery.item= Filter(AddColumns(Table1,"Name",LookUp(Table2,PersonnelNumber=Table1[@FieldA],Name)),FieldB="003") 

  • octaking Profile Picture
    320 on at

    Hi @mr-dang 

     

    I have a similar case but I can't make this formula work. Do you have any idea?

     

    AddColumns(Filter(Approvals,Status = 'Status (Approvals)'.'0', Email = User().Email),"Email",LookUp('Approval Requests','Approval Stage Key' = Label14_3.Text,AsType(Owner, Usuarios).'Correo electrónico principal'))

     

    68592668_411728939695434_2002545200592846848_n.jpg

  • octaking Profile Picture
    320 on at

    Hi @mr-dang 

     

    I have a similar case but I can't make this formula work. Do you have any idea?

     

    AddColumns(Filter(Approvals,Status = 'Status (Approvals)'.'0', Email = User().Email),"Email",LookUp('Approval Requests','Approval Stage Key' = Label14_3.Text,AsType(Owner, Usuarios).'Correo electrónico principal'))

     

    68592668_411728939695434_2002545200592846848_n.jpg

     

     

    What I want to do is get the owner of Approval request

  • Joe_Fox Profile Picture
    67 on at

    @Mike8Looks like you solved the previous person's problem, how about this one: I want to use both of the following at the same time:

     

    AddColumns('Calendar template', "AddedByCount", CountIf(Split(AddedBy, ";"), Result = User().FullName), "DeletedByCount", CountIf(Split(DeletedBy, ";"), Result = User().FullName))
    Filter('Calendar template',Date>=DateAdd(Today(),-30,Days) && Date<=Today() && ((User().FullName in AddedBy) && User().FullName in DeletedBy) || (Date>=DateAdd(Today(),-30,Days) && Date<=Today() && Not(User().FullName in AddedBy)))

     

    Is it possible? I tried using something similar to your solution but got myriad errors! This was my effort:

     

    AddColumns(Filter(('Calendar template',Date>=DateAdd(Today(),-30,Days) && Date<=Today() && ((User().FullName in AddedBy) && User().FullName in DeletedBy) || (Date>=DateAdd(Today(),-30,Days) && Date<=Today() && Not(User().FullName in AddedBy))),'Calendar template', "AddedByCount", CountIf(Split(AddedBy, ";"), Result = User().FullName), "DeletedByCount", CountIf(Split(DeletedBy, ";"), Result = User().FullName))

     

  • Joe_Fox Profile Picture
    67 on at

    I think I worked it out so just to close the loop:

     

    Filter(AddColumns('Calendar template', "AddedByCount", CountIf(Split(AddedBy, ";"), Result = User().FullName), "DeletedByCount", CountIf(Split(DeletedBy, ";"), Result = User().FullName)),Date>=DateAdd(Today(),-30,Days) && Date<=Today() && ((User().FullName in AddedBy) && User().FullName in DeletedBy) || (Date>=DateAdd(Today(),-30,Days) && Date<=Today() && Not(User().FullName in AddedBy)))
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    hi @mr-dang trying this... get an incompatible type error with:

    PersonnelNumber=Table1[@FieldA]

    this statement doesn't compile.  Complains right side is a "table" - where left is a number.

     

    @Mike8 I think you've recommended the same?

     

  • WCarterMVUSD Profile Picture
    101 on at

    I am getting the same error, the AddColumns with Lookup works fine if I use the unfiltered source, but if I filter the source then the Lookup comparison complains the column on the right side (my filtered table) is returning a table type instead of the number type of a single record in that column. I suspect this means it is returning all the values of the column instead of just the current record's value. Were you ever able to get this working, and if so what was the solution?

     

    Does not work: 

    ShowColumns(AddColumns(Filter('pbi.Students_byMonth', SY = Dropdown1.Selected.Result),"School", LookUp(LOC, CD = 'pbi.Students_byMonth'[@SC],NM)),"ID","School","SY")

     

    But if I replace the lookup with a static value I can filter:

    ShowColumns(AddColumns(Filter('pbi.Students_byMonth', SY = Dropdown1.Selected.Result),"School", 1),"ID","School","SY")

     

    or if I don't filter the source I can use the lookup

    ShowColumns(AddColumns('pbi.Students_byMonth',"School", LookUp(LOC, CD = 'pbi.Students_byMonth'[@SC],NM)),"ID","School","SY")

     

    But trying to combine the two, a filter and a lookup, seems to need a bit more coaxing.

  • HKICE Profile Picture
    241 on at

    Thanks #Mike8

    Only the second option worked:

    Filter(AddColumns(Table1,"Name",LookUp(Table2,PersonnelNumber=Table1[@FieldA],Name)),FieldB="003")

     

    The first one gave errors.

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 339 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 289

#3
Mohsin Ali Profile Picture

Mohsin Ali 228

Last 30 days Overall leaderboard