cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
minoLOB
Frequent Visitor

RemoveIf function doesn't work

The RemoveIf function won't work no matter how I try to alter my condition.

 

My datasource is SQL server.

The datatype of the column I'm trying to use in the condition is nvarchar.

 

The code is:  RemoveIf('[dbo].[TestColSQL]';Nmrappel = varNumeroAppel)

 

Nmrappel is the column name.

 

varNumeroAppel is a global variable storing the equivalent of Nmrappel from another source.

It is set by a button in a gallery with the code Set(varNumeroAppel;ThisItem.'Appel #') where 'Appel #'

is the corresponding Nmrappel value from another table.

 

I tried text() and value() on either or both Nmrappel and varNumeroAppel in the RemoveIf.

Nothing works. When I select the button, nothing happens and all the targeted records remain in the

SQL table. The only thing that works is putting "x" as the condition where x is the actual value that is being

passed to the variable.

 

In the attached printscreen, the red bordered label above the load button has its Text property set to varNumeroAppel.

The red bordered label gallery item is the corresponding Nmrappel record value. The RemoveIf function is in the OnSelect

property of the load button.

 

1 ACCEPTED SOLUTION

Accepted Solutions
CliveEastwood
Frequent Visitor

Use Remove against the SQL connector as RemoveIf doesn't work. RemoveIf is predominently aimed at collections I've found.

 

Remove will work use the following syntax

 

Remove('[dbo].[TestColSQL]',Filter('[dbo].[TestColSQL]',Text(Nmrappel) = Text(varNumeroAppel)))

View solution in original post

9 REPLIES 9
v-yutliu-msft
Community Support
Community Support

Hi @minoLOB ,

Could you tell me the data type of Nmrappel field and Appel field?

Pleace check whether the variable varNumeroAppel has the right value when you act the RemoveIf function.

You need to compare two data that is the same type.

You also need to make sure that the variable is valid when acting the RemoveIf function.

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yutliu-msft ,

 

Both Nmrappel and 'Appel #' are nvarchar data type. They are in different tables of the same SQL database.

 

On the attached printscreen, the label above the load button is simply there to show me the value of the variable varNumeroAppel.

When I go look in variables tab from the left menu, the variable always has the correct value.

 

I tried to use the text() and value() functions in every possible way on the 'Nmrappel = varNumeroAppel' part of my function to make sure the compared data were of the same type. To no avail.

 

Since it is displayed in the label as I select the button to call the RemoveIf function, I supposed the variable is always valid as the moment I use it.

 

e.g.   RemoveIf('[dbo].[TestColSQL]';Nmrappel = varNumeroAppel) where varNumeroAppel = 9-59 won't work

 

but   RemoveIf('[dbo].[TestColSQL]';Nmrappel = "9-59") does work.

 

All that while the label whose text is set to varNumeroAppel displays 9-59 and 9-59 is display in the variable's value column in the variable menu.

Hey @minoLOB 

 

Can you try to update the expression as:
 
RemoveIf('[dbo].[TestColSQL]';Text(Nmrappel) = Text(varNumeroAppel))
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Hi @yashag2255 ,

 

Unfortunately, I already tried but it doesn't work. I also tried these and all the same using the value() function instead

 

RemoveIf('[dbo].[TestColSQL]';Nmrappel = Text(varNumeroAppel))

RemoveIf('[dbo].[TestColSQL]';Text(Nmrappel) = varNumeroAppel)

 

but still nothing happens.

 

Also, another strange fact is that the gallery's item property is Filter('[dbo].[TestColSQL]';Nmrappel=varNumeroAppel).

 

Filter() takes the condition while RemoveIf() doesn't.

 

Hey @minoLOB 

 

This is really strange! Can you try to update the expression as:
 
RemoveIf('[dbo].[TestColSQL]';varNumeroAppel exactin Nmrappel)
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

@yashag2255 

Even stranger, it didn't work so I went through a couple of other records and on this one it worked except for the item circled in red.

For that one, I had to put in ' = "9-47" ' to remove it

 

Capture1.PNG

 

Here is the SQL query for that particular case

 

 

Capture2.PNG

CliveEastwood
Frequent Visitor

Use Remove against the SQL connector as RemoveIf doesn't work. RemoveIf is predominently aimed at collections I've found.

 

Remove will work use the following syntax

 

Remove('[dbo].[TestColSQL]',Filter('[dbo].[TestColSQL]',Text(Nmrappel) = Text(varNumeroAppel)))

It doesn't work on all of sets of records. Some work and some others don't. I just can't see what could be the difference between them. They were all written on the datasource with the same patch fucntion.

 

The only syntax that consistently work on any given set of records is still

 

RemoveIf('[dbo].[TestColSQL]'; Nmrappel = "x")

 

where x is the Nmrappel value     e.g.  "9-48"

Thanks @CliveEastwood ,

 

This does it for the time being. I wasn't too keen on using Remove() because I probably will have some delegation issue.

Once it is fully deployed, the datasource will reach the million row within the first year.

 

I guess that leaves me quite some time to figure out something else or for PowerApps to update with features that will address this kind of need. 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,592)