- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Filtering DirectQuery table based on import mode table - visuals
I have DirectQuery table [VendorTransaction](Vendor,Invoice,Amt) and 2 import tables: ExcludeVendor(Vendor) and ExcludeInvoice(Invoice).
I would need to exclude records in DirectQuery table [VendorTransaction](Vendor,Invoice,Amt) that exist as Vendor in ExcludeVendor and Invoice in ExcludeInvoice. I tried to use this measure, it worked on Visual with granularity similar to [VendorTransaction](Vendor,Invoice,Amt) but return different result (Amt) on Visuals with different granularity (Vendor or Total Amount). Are there any other ways to filter/exclude? I cannot use merge as as [VendorTransaction] is Direct Query table.
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

ExcludeVendorExcel =
CALCULATE (
SUM ( VendorTransactionMeasure[Amount] ),
KEEPFILTERS (
NOT VendorTransaction[Vendor] IN VALUES ( ExcludeVendor[Vendor] )
&& NOT VendorTransaction[Invoice] IN VALUES ( ExcludeInvoice[Invoice] )
)
)
seems to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

You could try
ExcludeVendorExcel =
CALCULATE (
COUNTROWS ( VendorTransaction ),
KEEPFILTERS (
NOT VendorTransaction[Vendor] IN VALUES ( VendorExclusion[Vendor] )
)
)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Thank you @johnt75 , I tried this logic on visuals with different granularity and, unfortunatelly, this filter returned different result for Amount.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @Julia1234 ,
When working with a DirectQuery table and attempting to filter it using imported tables, the challenge lies in ensuring consistent results across visuals with different granularities. Since merging is not an option with DirectQuery, here’s an alternative approach using DAX measures and relationships.
Create Filtering Logic with Measures:
Use measures to dynamically exclude rows from the VendorTransaction table based on ExcludeVendor and ExcludeInvoice.
Here’s how:
Measure: Exclude Rows
ExcludeFilter = IF ( NOT ( VendorTransaction[Vendor] IN VALUES ( ExcludeVendor[Vendor] ) || VendorTransaction[Invoice] IN VALUES ( ExcludeInvoice[Invoice] ) ), 1, 0 )
Measure: Filtered Amount
FilteredAmt = CALCULATE ( SUM ( VendorTransaction[Amt] ), FILTER ( VendorTransaction, [ExcludeFilter] = 1 )fUse FilteredAmt in your visuals instead of Amt. This will ensure that only rows not excluded by ExcludeVendor and ExcludeInvoice are considered, regardless of the visual’s granularity.
Alternative Approach: Use Composite Models
If your DirectQuery source allows, you can enable a Composite Model. This would let you create relationships between VendorTransaction and the imported tables (ExcludeVendor and ExcludeInvoice) directly in Power BI.
Steps:
- Ensure relationships between:
- VendorTransaction[Vendor] and ExcludeVendor[Vendor]
- VendorTransaction[Invoice] and ExcludeInvoice[Invoice]
- Use a calculated column in the VendorTransaction table to filter rows:
IsExcluded = IF ( VendorTransaction[Vendor] IN VALUES ( ExcludeVendor[Vendor] ) || VendorTransaction[Invoice] IN VALUES ( ExcludeInvoice[Invoice] ), TRUE, FALSE )
- Create a measure to sum only non-excluded rows:
FilteredAmt = CALCULATE ( SUM ( VendorTransaction[Amt] ), VendorTransaction[IsExcluded] = FALSE )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @FarhanJeelani Thank you for your ideas!
I tried creating this measure, but got error: A single value for column 'Vendor' in table 'VendorTransaction' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
Should an aggregate function be added?
ExcludeFilter =
IF (
NOT (
VendorTransaction[Vendor] IN VALUES ( ExcludeVendor[Vendor] )
|| VendorTransaction[Invoice] IN VALUES ( ExcludeInvoice[Invoice] )
),
1,
0
)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,
Please share some sample data to work with and show the expected result. Share data in a format that can be pasted in an MS Excel file.
Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @Ashish_Mathur Thank you for responding,
Direct Tables (not db tables but from model.bim) . VendorTransaction related to VendorTransactionMeasure by ID.
Excpected result: 1000 = 400+ 600
IDs 1,2,3,5 excluded, IDs 4 and 6 included into Amount calculation
1.Direct Tables
VendorTransaction
Vendor | Invoice | ID |
V123 | INV456 | 1 |
V124 | INV457 | 2 |
V125 | INV458 | 3 |
V125 | INV459 | 4 |
V127 | INV460 | 5 |
V127 | INV461 | 6 |
VendorTransactionMeasure
ID | Amount |
1 | 100 |
2 | 200 |
3 | 300 |
4 | 400 |
5 | 500 |
6 | 600 |
2.Import Tables
ExcludeVendor
Vendor |
V123 |
V124 |
ExcludeInvoice
Invoice |
INV458 |
INV460 |
So basically, the report uses existing tabular model.bim with direct connection, and exclusion list is needed on top to exclude Vendors and Invoices from VendorTransactions and VendorTransactions.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,
Are you allowed to create calculated column formulas?
Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

No, as the report is based on tabular model tables with direct query and I am trying to put exclusion list (import mode) on top. It is not possible to create calculated column based on a columns from the model.

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

User | Count |
---|---|
83 | |
78 | |
52 | |
37 | |
36 |
User | Count |
---|---|
104 | |
85 | |
47 | |
44 | |
43 |