Forum Discussion
Filter by Max Date or Selected Date
- Anonymous9 years ago
Hi inescastelhano,
You can try to use below formula if it suitable for your requirement:Result = IF(COUNTROWS('Calendar')<>COUNTROWS(ALL('Calendar')),//check all selected or not select "Distinct Count: "&CALCULATE(DISTINCTCOUNT('Link'[Employee]),VALUES('Calendar'[Date])), "Last Month: "&MONTH(LASTDATE('Calendar'[Date])))Notice: you should ensure these tables contains relationship and the cross filter direction is setting to 'both'.
Regards,
Xiaoxin Sheng
Should be something like this but it doesn't work:
Headcount = CALCULATE(
DISTINCTCOUNT ( Link[Employee Nr] ), 'Calendar'[IsLatestYearMonth]=if(MONTH('Calendar'[Id_Date]) = MONTH(LASTDATE ( 'Calendar'[Id_Date])),0,1),
FILTER ('Calendar',MONTH('Calendar'[Id_Date]) = MONTH(LASTDATE ( 'Calendar'[Id_Date]))),
FILTER('Calendar', YEAR('Calendar'[Id_Date]) = YEAR(LASTDATE ( 'Calendar'[Id_Date])))
)
but I get an error saying "The expression contains multiple columns, but only a single column can be used in a True/False epression that is used as a table filter expression".
you dont need to create 2 filters (it will behave like an or then)
CALCULATE (
DISTINCTCOUNT ( Link[Employee Nr] ),
'Calendar'[IsLatestYearMonth]
= IF (
MONTH ( 'Calendar'[Id_Date] ) = MONTH ( LASTDATE ( 'Calendar'[Id_Date] ) ),
0,
1
),
FILTER (
'Calendar',
MONTH ( 'Calendar'[Id_Date] ) = MONTH ( LASTDATE ( 'Calendar'[Id_Date] ) )
&& YEAR ( 'Calendar'[Id_Date] ) = YEAR ( LASTDATE ( 'Calendar'[Id_Date] ) )
)
)
- inescastelhano9 years agoFrequent Visitor
I get an error saying "The expression contains multiple columns, but only a single column can be used in a True/False epression that is used as a table filter expression"...