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 / If statement "Not equa...
Power Apps
Unanswered

If statement "Not equal to "Select""

(0) ShareShare
ReportReport
Posted on by

I am trying to write an If statement like "If(IsBlank(field)" but I need it to be "If not = to "Select...""(field)"  How can you write something like that?  I want the action to run as long as the field value is not "Select..."

Categories:
I have the same question (0)
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @PowerAid,

    It sounds like you want to test a field to exclude ones that have "Select..." in it. I am not sure of how you want to use this but if you wanted to only show items in a gallery or DataTable, theItems property would be Filter(datasource,field<>"Select..."). If I am misunderstanding what you are trying to do, please explain.  If this answers your question please mark this discussion as solved.

  • PowerAid Profile Picture
    on at

    @Drrickryp wrote:

    Hi @PowerAid,

    It sounds like you want to test a field to exclude ones that have "Select..." in it. I am not sure of how you want to use this but if you wanted to only show items in a gallery or DataTable, theItems property would be Filter(datasource,field<>"Select..."). If I am misunderstanding what you are trying to do, please explain.  If this answers your question please mark this discussion as solved.


    I am trying to change the following formula:

     

    ForAll(RevenuePreDefinedCollection, If(IsBlank(CategoryCC), Patch('Revenue Pre-Defined Categories', Defaults('Revenue Pre-Defined Categories'), {Title: CategoryCC, AmountEach: AmountEachCC, Quantity: QuantityCC, Subtotal: SubtotalCC, MasterID: Form1.LastSubmit.ID})))

     

    Where it says If(IsBlank(CategoryCC)  - CategoryCC is a dropdown field with a default value of "Select...".  I need the patch to run only if the CategoryCC is not equal to "Select..."

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    I believe ForAll(RevenuePreDefinedCollection, If(Or(IsBlank(CategoryCC),CategoryCC.Selected.Value<>"Select...")), Patch('Revenue Pre-Defined Categories', Defaults('Revenue Pre-Defined Categories'), {Title: CategoryCC, AmountEach: AmountEachCC, Quantity: QuantityCC, Subtotal: SubtotalCC, MasterID: Form1.LastSubmit.ID}))) should work.

     

    If I'm correct, the If statement reduces to true if CategoryCC is blank or does not contain the Selected Value "Select...". and when the statement is true, then the patch will run.  Give it a try and see if it works.

  • PowerAid Profile Picture
    on at

     


    @Drrickryp wrote:

    I believe ForAll(RevenuePreDefinedCollection, If(Or(IsBlank(CategoryCC),CategoryCC.Selected.Value<>"Select...")), Patch('Revenue Pre-Defined Categories', Defaults('Revenue Pre-Defined Categories'), {Title: CategoryCC, AmountEach: AmountEachCC, Quantity: QuantityCC, Subtotal: SubtotalCC, MasterID: Form1.LastSubmit.ID}))) should work.

     

    If I'm correct, the If statement reduces to true if CategoryCC is blank or does not contain the Selected Value "Select...". and when the statement is true, then the patch will run.  Give it a try and see if it works.

     

    It is telling me that there are an invalid number of arguments.  I should clarify that CategoryCC is not an actual field.  Its a column in a collection.  The dropdown Default property is set to CategoryCC.  The dropdown name is DropDownPredefinedCategories


     

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    ForAll(RevenuePreDefinedCollection,
     If(Or(IsBlank(CategoryCC),CategoryCC.Selected.Value<>"Select...")),
     Patch('Revenue Pre-Defined Categories', Defaults('Revenue Pre-Defined Categories'), {Title: CategoryCC, AmountEach: AmountEachCC, Quantity: QuantityCC, Subtotal: SubtotalCC, MasterID: Form1.LastSubmit.ID}),
      false)) ?

  • PowerAid Profile Picture
    on at

    @Drrickryp wrote:

    ForAll(RevenuePreDefinedCollection,
     If(Or(IsBlank(CategoryCC),CategoryCC.Selected.Value<>"Select...")),
     Patch('Revenue Pre-Defined Categories', Defaults('Revenue Pre-Defined Categories'), {Title: CategoryCC, AmountEach: AmountEachCC, Quantity: QuantityCC, Subtotal: SubtotalCC, MasterID: Form1.LastSubmit.ID}),
      false)) ?


    Still getting invalid arguments error.

  • PowerAid Profile Picture
    on at

    What about If(Not or !  ?

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @PowerAid,

    I reviewed the information you provided and it appears that since the Patch command includes the Defaults('Revenue Pre-Defined Categories') parameter you are adding new records to your datasource.  Your ForAll command implies that you are bulk adding a Collection of records (RevenuePreDefinedCollection) to the datasource ('Revenue Pre-Defined Categories' ).  In this case, it is easier to filter the collection before loading it to the datasource.  ForAll(Filter(RevenuePreDefinedCollection,CategoryCC<>"Select..."), Patch(blah,blah.  If this is not the case, please let me know. You may want to review https://powerapps.microsoft.com/en-us/blog/bulk-update-using-forall-and-patch/

  • Verified answer
    PowerAid Profile Picture
    on at

    @Drrickryp wrote:

    Hi @PowerAid,

    I reviewed the information you provided and it appears that since the Patch command includes the Defaults('Revenue Pre-Defined Categories') parameter you are adding new records to your datasource.  Your ForAll command implies that you are bulk adding a Collection of records (RevenuePreDefinedCollection) to the datasource ('Revenue Pre-Defined Categories' ).  In this case, it is easier to filter the collection before loading it to the datasource.  ForAll(Filter(RevenuePreDefinedCollection,CategoryCC<>"Select..."), Patch(blah,blah.  If this is not the case, please let me know. You may want to review https://powerapps.microsoft.com/en-us/blog/bulk-update-using-forall-and-patch/


    You, Sir, are a freakin genius.  You understood my code perfectly and your Filter idea worked!  Thank you, Thank you, Thank you!!!!!!!!

  • dixonbridgeta Profile Picture
    125 on at

    How would you do this just for a combobox itself and not in a patch function. Example:

     

    If (DataCardValue2.Selected.Value = "New" && DataCardValue3.Selected.Value = "Cloud",
    [
    "Microsoft Cloud - East US",
    "Microsoft Cloud - West US"
    ],
    DataCardValue2.Selected.Value = "New" && DataCardValue3.Selected.Value = "OnPrem",
    Filter(CMDB_SERVERS, Location <> "Microsoft Cloud - East US" || "Microsoft Cloud - West US")) ----> this is the problem area. I want it to show everything else in the list except for the those two ^

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 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard