Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
I have two tables:
Table1:
| ID | Letter |
| 1 | a |
| 2 | b |
| 3 | c |
| 4 | d |
| 5 | e |
| 6 | f |
| 7 | g |
| 8 | h |
| 9 | i |
And a virtual table, Table 2
ID |
| 1 |
| 2 |
How do I find the intersection (i.e. all rows in Table1 that has an ID in Table2). There are a large number of rows, so the DAX function must be efficient.
Thanks!
Thanks Owen, but I couldn't use this as a solution.
TREATAS() requires the name number of columns in the table I believe.
Can I not use CONTAINS?
The ultimate goal is to filter a table based on a random sample (Table2). Two parallel calculations have to be done from the same random sample so I'm getting the sample as a concatenated list and then building a virtual table using that list inorder to filter another virtual table.
That's right, TREATAS requires the same number of columns as column references provided.
If Table2 contains more than just the ID column, then just use SELECTCOLUMNS to select the ID column:
CALCULATETABLE (
Table1,
TREATAS (
SELECTCOLUMNS ( Table2, "ID", Table2[ID] ),
Table1[ID]
)
)
It is possible to use CONTAINS with FILTER, but performance is likely to be worse.
https://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/
Regards,
Owen
Hi,
I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.
It is for creating a new table.
Intersect table =
CALCULATETABLE ( Table1, INTERSECT ( VALUES ( Table1[ID] ), Table2 ) )
Hi there,
Based on what you've posted, I would suggest using TREATAS to apply Table2 as a filter (I'm assuming Table2 has a single column).
For example, if you need an expression that returns the rows of Table1
CALCULATETABLE (
Table1,
TREATAS ( Table2, Table1[ID] )
)
What is the ultimate goal, i.e. where would the intersecting rows of Table1 be used?
Regards,
Owen
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 4 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 21 | |
| 10 | |
| 8 | |
| 7 | |
| 6 |