Forum Discussion
DAX filter based on Todays date?
Hi - can anyone help?
Am trying to calculate a sum with multiple filters including one that looks at a date in a field and should add a filter if the date is LESS THAN today. The error this produces is that a "function 'FILTER' has been used in a True/False expression that is used as a table filter expression. This is not allowed."
Here is my DAX expression:
Hi sputnik76
Believe that the problem with your measure is where you have is the [Workdays] * 7.6 , when using the CALCULATE function the first parameter is the calculation from the second parameter on you must use the filters you want to apply in this case you are applying a multiplication as a filter so the check is if that multiplication is true or false.
Another problem may be where you refer TRUE if this is refering to a result of TRUE/FALSE you need to use the TRUE() if its a written value on your column you should use the "" to make it as text
Check the two measures below:
Max Possible Hours = CALCULATE ( COUNT ( users[full name] ) * [Workdays] * 7.6, FILTER ( users, users[is_active] = TRUE() ), FILTER ( 'Harvest Inactive List', 'Harvest Inactive List'[inactive date] < TODAY () ) )Max Possible Hours = CALCULATE ( COUNT ( users[full name] ) * [Workdays] * 7.6, FILTER ( users, users[is_active] = "TRUE" ), FILTER ( 'Harvest Inactive List', 'Harvest Inactive List'[inactive date] < TODAY () ) * [Workdays] * 7.6 )Regards,
Mfelix
1 Reply
- MFelix
Super User
Hi sputnik76
Believe that the problem with your measure is where you have is the [Workdays] * 7.6 , when using the CALCULATE function the first parameter is the calculation from the second parameter on you must use the filters you want to apply in this case you are applying a multiplication as a filter so the check is if that multiplication is true or false.
Another problem may be where you refer TRUE if this is refering to a result of TRUE/FALSE you need to use the TRUE() if its a written value on your column you should use the "" to make it as text
Check the two measures below:
Max Possible Hours = CALCULATE ( COUNT ( users[full name] ) * [Workdays] * 7.6, FILTER ( users, users[is_active] = TRUE() ), FILTER ( 'Harvest Inactive List', 'Harvest Inactive List'[inactive date] < TODAY () ) )Max Possible Hours = CALCULATE ( COUNT ( users[full name] ) * [Workdays] * 7.6, FILTER ( users, users[is_active] = "TRUE" ), FILTER ( 'Harvest Inactive List', 'Harvest Inactive List'[inactive date] < TODAY () ) * [Workdays] * 7.6 )Regards,
Mfelix