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 / Need a filter that do ...
Power Apps
Answered

Need a filter that do not return a value if match a condition

(0) ShareShare
ReportReport
Posted on by 62

Hi everyone,

 

I'm working on an app that works with a big data base that can have multiple status for the same item.

 

For example:

 

Geometry          Color

Square             Blue

Square             Red

Circle               Yellow

Triangle           Blue

Square            Red

Circle              Red

Triangle          Pink

 

I need to filter the geometries that DO NOT have de Blue color.

 

I tried this code below, but it returns to me the first row that do not have "Blue", instead of returning the geometry that do not have the color "Blue" on its colors.

 

Filter(
ForAll(
Distinct(
DataBase,
Geometry
),

LookUp(
DataBase,
Geometry = Result
)
),

Color <> "Blue"

)

 

I tried to figure it out alone for days, but no idea how to solve it. Can someone help me?

 

Thanks,

Categories:
  • subsguts Profile Picture
    1,259 Moderator on at

    You could just do Filter(Database,Color<>"Blue")

     

    However, how BIG is BIG?  And what type of database are you using?  Depending on the answer to these questions you may run into delegation issue.

     

    Hope this helps.

  • subsguts Profile Picture
    1,259 Moderator on at

    I wanted to add that you probably want to do a little more than what I posted:

     

    The following will give you just the unique geometries that don't have the color "Blue".
    Distinct(Filter(Database,Color<>"Blue"),Geometry)

    Please note, that if you use this in your Items property of a gallery the list of Geometries, will not be in the Item.Geometry.  Rather, it will be in the Item.Result since the Distinct function only returns 1 value and it is put into "Result", not "Geometry".

    Again, I hope this helps solve your problem.

  • MMeyrelles Profile Picture
    62 on at

    It's something like 15k+ rows, so I have to put all of them into a collection and show these "unique" data into a gallery.

     

    When I use this Filter(Database,Color<>"Blue"), it returns to me data like "Square Red" and "Triangle Pink", but I don't want them since they have "Blue" associated to them on other rows.

  • MMeyrelles Profile Picture
    62 on at

    I think it was not clear on the post, but what I want as a return is only the Geometry that don't have "Blue" associated to it. The color itself is irrelevant to show at the gallery.

  • Verified answer
    subsguts Profile Picture
    1,259 Moderator on at

    Ok, fingers crossed :-), I hope this will get you to a solution.  Here's what I did: 

     

    Step 1:  I created a collection to use for the test and added this to a button in my App to generate the collection colDatabase:

     

    ClearCollect(colDatabase, Table({ Geometry: "Square", Color: "Red"},
    { Geometry: "Rhombus", Color: "Pink"},
    { Geometry: "Circle", Color: "Orange"},
    { Geometry: "Rhombus", Color: "Yellow"},
    { Geometry: "Circle", Color: "Blue"},
    { Geometry: "Triangle", Color: "Purple"},
    { Geometry: "Square", Color: "Red"},
    { Geometry: "Square", Color: "Blue"},
    { Geometry: "Triangle", Color: "Pink"}
    ))

     

    Step2:  I created a collection called "OnlyBlue" using the following statement, also added in a button in the App, which contains any Geometry that has the color Blue associated with it (so in this case it should only have Circle and Square.

    ClearCollect(colHasBlue,Distinct(Filter(colDatabase,Color="Blue"),Geometry))

     

    Step3:  I created the statement that uses the "OnlyBlue" collection to display only those distinct Geometries that don't have the color blue associate with them.

    Distinct(Filter(colDatabase,!(Geometry in colHasBlue)),Geometry)

     

    This appears to work.  I tried to combine the two statements together, but it didn't want to cooperate, but I believe you can run the first ClearCollect separately, and I actually find it easier to understand how and why it works when they are kept separately.

     

    Here is a picture of the App.  To summarize, the "No Blue" gallery is the results I believe you are looking for and it's Item property is equal to Distinct(Filter(colDatabase,!(Geometry in colHasBlue)),Geometry). The "Only Blue" gallery, just shows what is in the OnlyBlue collection and it's Item property is equal to ClearCollect(colHasBlue,Distinct(Filter(colDatabase,Color="Blue"),Geometry)).  Finally, I added a gallery, which just shows everything that is in the colDatabase collection I created.

     

    Please let me know if this resolves your problem and or if you have additional questions. 

     

    subsguts_0-1666814428283.png

     

     

  • MMeyrelles Profile Picture
    62 on at

    It worked exactly how I needed. 

     

    Thanks very much!

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 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 194 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 150

Last 30 days Overall leaderboard