Forum Discussion
CALCULATE measure with date filter
Hello!
My data set:
'Date'[Date] - Default data table, used as report filter
Table:
| Product_ID | Date_Start | ... |
| 2432 | 20.02.2022 | |
| 3522 | 21.02.2022 | |
| ... | ... |
Task: Count number of distinct Product which started at given date
gives empty result for any date
No error reported in PBI
Sounds like the entries in 'Date'[Date] aren't formatted as proper dates. Hence the conversion to a correct date by a simple mathematical operation (for example, your subtraction of 1).
Regards
- Anonymous4 years ago
Ok, so everything looked fine at first glance.
But changing date table from defined in report by:Date = CALENDAR(DATE(1990, 01,01),DATE(2099,12,31))
to Data table generated in power query solved the issue.
Thanks for guidance.
5 Replies
- Jos_Woolley
Solution Sage
Sounds like the entries in 'Date'[Date] aren't formatted as proper dates. Hence the conversion to a correct date by a simple mathematical operation (for example, your subtraction of 1).
Regards
- AnonymousNot applicable
Date = CALENDAR(DATE(1990, 01,01),DATE(2099,12,31))
and column: 'Date'[Date], data type is "Date" - AnonymousNot applicable
Ok, so everything looked fine at first glance.
But changing date table from defined in report by:Date = CALENDAR(DATE(1990, 01,01),DATE(2099,12,31))
to Data table generated in power query solved the issue.
Thanks for guidance.
- Jos_Woolley
Solution Sage
Hi,
MyMeasure := VAR ThisDate = MAX( 'Date'[Date] ) RETURN CALCULATE( DISTINCTCOUNT( 'Table'[Product_ID] ), 'Table'[Date_Start] = ThisDate )which is identical to:
MyMeasure := VAR ThisDate = MAX( 'Date'[Date] ) RETURN CALCULATE( DISTINCTCOUNT( 'Table'[Product_ID] ), FILTER( ALL( 'Table' ), 'Table'[Date_Start] = ThisDate ) )Regards
- AnonymousNot applicable
I have already tried this alternative , no change. As in my post, it works with
ThisDate = MAX( 'Date'[Date] ) - 1