Forum Discussion
jmkvalsund
Helper III
3 years agoUsing measure in a DAX filter does not work
Im trying to use a measure in a DAX filter to count the numbers of customers for each Key Account Manager (KAM) at a given date, but it does not seem to work. My measure is calculated like this, a...
- 3 years ago
Does it work if you store the result of the measure in a variable ?
M_NumberOfCustomersTwoMonthsAgo = VAR ReferenceDate = [M_StartDate2MonthsInterval] RETURN CALCULATE ( DISTINCTCOUNT ( 'Sales'[CustomerID] ), 'Sales'[KAM_email] = "[email protected]", 'Sales'[DateID] = ReferenceDate )
johnt75
Super User
3 years agoYou can't use measures as filters because they are calculated at the aggregate level not the individual row level. To calculate at the row level you need to use an iterator to introduce a row context, so you need to use the FILTER function.
Try
M_NumberOfCustomersTwoMonthsAgo =
CALCULATE (
DISTINCTCOUNT ( 'Sales'[CustomerID] ),
FILTER (
'Sales',
'Sales'[KAM_email] = "[email protected]"
&& 'Sales'[DateID] = [M_StartDate2MonthsInterval]
)
)