cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

If statement "Not equal to "Select""

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..."

1 ACCEPTED SOLUTION

Accepted Solutions


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

View solution in original post

9 REPLIES 9
Super User II
Super User II

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.


@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..."

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.

 


@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


 

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)) ?


@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.

What about If(Not or !  ?

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/


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

View solution in original post

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (6,826)