cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Filter() delegation to SQL doesn't work properly

Hi,

 

When I use following syntax it gives me NO warning:

ClearCollect(collecton,Filter('[dbo].[PA_VIEW_VW]',USER_EMAIL=usr.Email));

 

When I use  following syntax it GIVES me a warrning and delegation is not working properly (not all rows are returned)

ClearCollect(collection,Filter('[dbo].[PA_VIEW_VW]',USER_EMAIL in otherCollection.emails));

This is not inline in  the article that Filter() function CAN be delegated.

IS there any workaround to check for more than 1 value? The number of records in

otherCollection.emails

 is non deterministic - it can be 1 or 10.

 

Regards,

KmL

9 REPLIES 9
v-micsh-msft
Community Support
Community Support

Hi @Anonymous,

 

The supported scenario for the in operator in SQL Server should be used as below, the right side of the in operator should be a column from the SQL Table:

 

Filter(DataBaseTable, "String" in Column)

Put the Column at the left side of the in operator is currently supported:

Filter(SQLTable, Column in [Values])

You may consider hold the SQL Table into a local collection, then do the filter as needed.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-micsh-msft

 

Unfortunately your answer is misleading for me - you present 2 examples with different approach and I'm confused which one is correct or when I should utilize in which moment.

 

Let me once again put examples with errors as above examples doesn't work for me.

 

Set(usr,User());
ClearCollect(backupScope,'[dbo].[PA_BackupScope_VW]');
ClearCollect(otherCollection,Filter(backupScope,BACKUP_TO=usr.Email));
//NOT WORKING - POWERAPPS BUG
ClearCollect(usrCustCat,Filter('[dbo].[PA_UserScope_VW]',USER_EMAIL in otherCollection.emails))
//Part of this formula cannot be evaluated remotely. Right side of "in" operator is not a column name.

ClearCollect(usrCustCat,Filter('[dbo].[PA_UserScope_VW]',otherCollection.emails in USER_EMAIL))
//2 errors
//otherCollection.emails - Invalid argument type. Cannot use Table values in this context/
//Delegation warning. This part "Filter" of this formula might not work correctly on large data sets. The data source might not be able to process the formula and might return an incomplete data set. Your application might not return correct results or behave correctly if the data set is incomplete.

 

Please note that I'm using on-premises gateway.

 

Regards,

KmL

 

EDIT: I can't store '[dbo].[PA_UserScope_VW]' in a local collection as it has over 6000 rows.

 

 

Hope the confusion gets clarified whether SQL supports delegable operator for IN or not. Can you please update the documentation with the good set of examples of how it works. 

 

Lots of forum answers/replies are misleading.

 

Will follow this post and watch for a solution by someone.

 

Thanks

DNN

Anonymous
Not applicable

@v-micsh-msft

Hi,

 

Please test on "On-premises data gateway" not on Azure.

 

Regards,

KML

Pankaj_1993
Frequent Visitor

Hi All,

I developed a simple application and publish it. When i opened that app through my phone, I noticed that it has already a login page. So i thought , I would take those loginid and show data in the screen on the basis of loginid.

I am not Dynamics365 DataSource.

 

For this I used filter and Set currentuser details in the OnStart of the Screen1[Set(e,User())] and in the Screen1 I am using a Blank Vertical Gallery and I have written in the Items property [Filter(CustomerDeliveryStatusDatas_1,UserId=e.Email)]

 

 

I have the exact same issue. "CaseStatus" is a text column in the datasource.

 

Filter('[dbo].[Cases]',ComboBox1.SelectedItems.Value in CaseStatus && QueuePicker.Selected.QueueID = QueueID)

This line gives me the error "Cannot use table values in this context". If i swap the the column and the combo...

 

Filter('[dbo].[Cases]',CaseStatus in ComboBox1.SelectedItems.Value && QueuePicker.Selected.QueueID = QueueID)

...everything works as expected but i get the delegation warning.

 

If i change the combobox to a dropdown (or set "SelectMultiple" to false) everything works with delegation to SQL, so the problems is "in" but only in some cases.

 

Is this considered to be a bug or is it by design?

Anonymous
Not applicable

adding in someone to review. 

 

@Anonymous 

Any feedback on this review yet?

 

I'm having similar issues.

So here's my three filters ...


Filter(
'[dbo].[Q2_ITEM_ANSWER]',
IGUID in '[dbo].[Q2_IA_UP_TGT]'.IGUID
)


Filter(
'[dbo].[Q2_ITEM_ANSWER]',
'[dbo].[Q2_IA_UP_TGT]'.IGUID in IGUID
)

Filter(
'[dbo].[Q2_ITEM_ANSWER]',
IGUID = 1
)

 

First gives delegation blue underline, second give table type red underline, and third works ok because it's "=" not "in".

 

Also, this is using Azure SQL, not DMG, so the issue seems to be the generic across both.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,747)