Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mmoore
Regular Visitor

How can I perform an OR filter on a DirectQuery, based on a second table?

I have a very large data set of purchase records which I am accessing via DirectQuery. 

 

I need to find all records where either (a) Category = Transportation or (b) Supplier is in a list of targeted suppliers

The list of targeted suppliers is in an Excel file on Sharepoint, and accessed in Import mode.

 

How can I filter the purchase records table based on the suppliers listed in the Target Supplier table?

In real life the unfiltered Purchase Records have millions of rows, and the Target Supplier table has around 100. 

 

data_mockup.png

 

As I understand it, since I am using DirectQuery I cannot use PowerQuery. It seems that RELATED and Natural Joins are also out. 

I am pretty new to PowerBI but have a lot of other data experience (SQL, Python, R). 

I'm running PowerBI desktop Version: 2.112.1161.0 64-bit (Dezember 2022). 

1 ACCEPTED SOLUTION

Hi @mmoore 

A calculated column on an import table can refer to other tables, but a calculated column on a DirectQuery table can still refer only to columns on the same table, but you can use a calculated table.

Maybe you can refer the follwing example.

Create a new table

Table 2 = SUMMARIZE(FILTER('Table',OR([Category]="Transportation",[Supplier] in VALUES('Table (2)'[Target Supplier]))),[Purchase ID],[Supplier],[Category],"IF",if([Category]="Transportation"&&[Supplier] in VALUES('Table (2)'[Target Supplier]),"Kept because target su and tra",IF([Category]="Transportation","Kept because  tra",IF([Supplier] in VALUES('Table (2)'[Target Supplier]),"Kept because target su "))))

vxinruzhumsft_0-1675328281832.png

 

You can refer to the following links about the limiations of direct query in composite mode

https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-composite-models#considerations-a...

https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-composite-models#calculated-table...

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
mmoore
Regular Visitor

Thank you for the advice. Unfortunately I get the error: 

 

> The column 'Purchases'[_IF] cannot be pushed to the remote data source and cannot be used in this scenario.

 

I believe this is because the Purchases data source is a DirectQuery SAP data source, and the operations available are limited. 

Hi @mmoore 

Do you have the edit permission of the dataset?

You may need to confirm that your permission of the data source, it can effect your operation of the dataset.

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

No, I have read-only access to the data set. It is a large organization and the reporting side doesn't have write access. 

Hi @mmoore 

A calculated column on an import table can refer to other tables, but a calculated column on a DirectQuery table can still refer only to columns on the same table, but you can use a calculated table.

Maybe you can refer the follwing example.

Create a new table

Table 2 = SUMMARIZE(FILTER('Table',OR([Category]="Transportation",[Supplier] in VALUES('Table (2)'[Target Supplier]))),[Purchase ID],[Supplier],[Category],"IF",if([Category]="Transportation"&&[Supplier] in VALUES('Table (2)'[Target Supplier]),"Kept because target su and tra",IF([Category]="Transportation","Kept because  tra",IF([Supplier] in VALUES('Table (2)'[Target Supplier]),"Kept because target su "))))

vxinruzhumsft_0-1675328281832.png

 

You can refer to the following links about the limiations of direct query in composite mode

https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-composite-models#considerations-a...

https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-composite-models#calculated-table...

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks, this did it! Because my data set is so large I had to hard code a date filter into the FILTER function for now, but now it runs and returns correct data.

v-xinruzhu-msft
Community Support
Community Support

Hi @mmoore 

You can refer to the following example.

You can create a new column

_IF = if([Category]="Transportation"&&[Supplier] in VALUES('Table (2)'[Target Supplier]),"Kept because target su and tra",IF([Category]="Transportation","Kept because  tra",IF([Supplier] in VALUES('Table (2)'[Target Supplier]),"Kept because target su ")))

Then filter the column to show data without blank value.

vxinruzhumsft_0-1675231615455.png

Output

vxinruzhumsft_1-1675231642627.png

Note: Based on your large dateset, it may take a long time to calculate it.

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.