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 / Filtering 2 columns in...
Power Apps
Answered

Filtering 2 columns in a gallery, but if column2 contains a value, then it should always ignore column1 for that row

(0) ShareShare
ReportReport
Posted on by 39
I have a gallery with a sharepoint list as the data source.
The sharepoint list has 2 columns, coumn1 and column2.
There is always a value in column1, but only sometimes a value in column2.
The gallery needs to be filtered using a variable named varA.
Column1 should be filtered by varA, except if column2 is not blank, then it should ignore column1 and try match column2 to varA.
 
Currently, this is what I have:
 
Filter(DataSource, column1= varA || column2= varA).
 
The problem I am facing, is that when varA matches the value in column1, but there is a value in column2, that row is still displayed. I need to only see rows where if column2 is blank, then it matches column1, but if column2 is not blank, then it will always ignore the value in column1.

Copilot is no help, although it does provide solutions that make sense in theory, they don't apply in practice.
Categories:
I have the same question (0)
  • mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at

    hey @s_raja 

     

    can you try this:

    Filter(DataSource, If(IsBlank(column2), column1 = varA, column2 = varA))
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • s_raja Profile Picture
    39 on at

    Hi @mmbr1606 ,

     

    this is the first thing that copilot asked me to do as well.
    After doing this, my gallery is showing me no rows at all, previously I was able to see some rows.

     

    Thanks

  • Verified answer
    mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at

    hey @s_raja 

     

    thanks for your reply, can u try this instead:

    Filter(
     DataSource,
     If(
     IsBlank(Trim(column2)),
     Lower(Trim(column1)) = Lower(Trim(varA)),
     Lower(Trim(column2)) = Lower(Trim(varA))
     )
    )
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • s_raja Profile Picture
    39 on at

    Hello @mmbr1606 ,

     

    Thanks for taking your time to help with this.

     

    Your solution was correct. I did not share the entire gallery filter earlier, and my test version contained an extra variable which was used by a button to allow the user to reset the gallery when varA changes. After removing this, I was able to filter the gallery correctly using your logic.

     

    Many thanks

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 326 Most Valuable Professional

#2
11manish Profile Picture

11manish 168

#3
sannavajjala87 Profile Picture

sannavajjala87 75 Super User 2026 Season 1

Last 30 days Overall leaderboard