# DAX Filter from multiple tables



## losamfr17 (Sep 14, 2020)

Hi,

I don't understand why my measure won't work.
I have two mock tables which are not related. I want to use tbl_Sales as a base and create a measure that will return each person's goal for their respective month.

My measure is "_Measure1 = CALCULATE( SUM( tbl_Goals[Goals] ) , FILTER( tbl_Goals, tbl_Goals[Month] = tbl_Sales[Month] && tbl_Goals[Name] = tbl_Sales[Name] ) )"_
I get an error message with this measure even though I see it offered as a solution to similar questions.

Could anyone please advise?


----------



## Matt Allington (Sep 15, 2020)

This measure can never work under any circumstances. The filter function has a row context - in short the means you can refer to any columns in that table. But you are not allowed to refer to columns in the sales table the way you have because those columns are not part of the goals table. You CAN refer to the columns in the sales table as long as you wrap a function around those columns, such as MAX().

You don’t show how you are wanting to use the measure, but you could try this.
_Measure1 = CALCULATE( SUM( tbl_Goals[Goals] ) , FILTER( tbl_Goals, tbl_Goals[Month] = MAX(tbl_Sales[Month]) && tbl_Goals[Name] = MAX(tbl_Sales[Name] ) ))_


----------



## losamfr17 (Sep 15, 2020)

Matt Allington said:


> This measure can never work under any circumstances. The filter function has a row context - in short the means you can refer to any columns in that table. But you are not allowed to refer to columns in the sales table the way you have because those columns are not part of the goals table. You CAN refer to the columns in the sales table as long as you wrap a function around those columns, such as MAX().
> 
> You don’t show how you are wanting to use the measure, but you could try this.
> _Measure1 = CALCULATE( SUM( tbl_Goals[Goals] ) , FILTER( tbl_Goals, tbl_Goals[Month] = MAX(tbl_Sales[Month]) && tbl_Goals[Name] = MAX(tbl_Sales[Name] ) ))_



Wow thank you so much for taking the time to respond. Gd bless you.


----------

