DAX Filter by values found in a column of another table

dicken

Active Member
Joined
Feb 12, 2022
Messages
283
Office Version
  1. 365
Platform
  1. Windows
I hope this illustrates what I would like to do i fist have a virtual table filtered for just green products, and then a second
for just red , I would like to filter the second table to show only customers or whatever that are contained in the first;

EVALUATE
VAR ttable =
CALCULATETABLE (
SUMMARIZE ( Table1, Table1[Customer], Table1[Product], Table1[Color] ),
Table1[Color] IN { "Red" }
)
VAR ttabletwo =
CALCULATETABLE (
SUMMARIZE ( Table1, Table1[Customer], Table1[Product], Table1[Color] ),
Table1[Color] IN { "Green" }
)
RETURN
ttabletwo



So this ttabletwo should be filtered to only those customers who appear in ttable,
I'm stuck on even the syntax and can't find much information about how I can refer to the first table I've tried
various such as ttable [Customer] , "Customer" etc. So direction to any information on this would be helpful.
Richard.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
If you make ttable a one column table of the items, then you should be able to use it in an IN clause in a filter - something like:

Excel Formula:
EVALUATE
VAR ttable =
CALCULATETABLE (
SUMMARIZE ( Table1, Table1[Customer]),
Table1[Color] = "Red"
)
VAR ttabletwo =
CALCULATETABLE (
SUMMARIZE ( Table1, Table1[Customer], Table1[Product], Table1[Color] ),
Table1[Color] = "Green"
)
RETURN
FILTER(ttabletwo,[Customer] IN ttable)
 
Upvote 1
Solution
If you make ttable a one column table of the items, then you should be able to use it in an IN clause in a filter - something like:

Excel Formula:
EVALUATE
VAR ttable =
CALCULATETABLE (
SUMMARIZE ( Table1, Table1[Customer]),
Table1[Color] = "Red"
)
VAR ttabletwo =
CALCULATETABLE (
SUMMARIZE ( Table1, Table1[Customer], Table1[Product], Table1[Color] ),
Table1[Color] = "Green"
)
RETURN
FILTER(ttabletwo,[Customer] IN ttable)
Thanks for the response, I was getting close, and put up a post on forum, linked, as you have I was using summarize to get a one column table but as a separate variable, did not get it to work but at least it looks like I was going in the right direction.

RD
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top