cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KML
Advocate I
Advocate I

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 @KML,

 

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.

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

@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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,376)