Forum Discussion
Date Filter Help
I would like to write Dax to select all 3 highlighted rows. I wrote this and it does not grab all 3 row values.
var _Max_Date = DATE(2023,08,31)
VAR _ENR_DATE = EOMONTH(_Max_Date,-2)+1
Filter( table,([MIN_ENR] >= _ENR_DATE && [MAX_ENR] <= _Max_Date))
I want to also select Max_ENR if it is > _Max_Date
- Anonymous2 years ago
Hi NilR ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a tables.
Table 2 = var _Max_Date = DATE(2023,08,31) VAR _ENR_DATE = EOMONTH(_Max_Date,-2)+1 return Filter('Table', [max_enr]> _Max_Date)Table 3 = var _Max_Date = DATE(2023,9,1) VAR _ENR_DATE = EOMONTH(_Max_Date,-3)+1 return Filter('Table', [max_enr] >= _ENR_DATE && [max_enr] <=_Max_Date)(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
6 Replies
- Alef_Ricardo_Resolver II
It seems like you want to select rows from a table where `MAX_ENR` is either between `_ENR_DATE` and `_Max_Date` or greater than `_Max_Date`. You can modify your DAX code to include this additional condition. Here's how you can do it:
```dax
VAR _Max_Date = DATE(2023,08,31)
VAR _ENR_DATE = EOMONTH(_Max_Date,-2)+1
EVALUATE
FILTER(
table,
([MAX_ENR] >= _ENR_DATE && [MAX_ENR] <= _Max_Date) || [MAX_ENR] > _Max_Date
)
```In this code, the `FILTER` function is used to select rows from the `table` where `MAX_ENR` is either between `_ENR_DATE` and `_Max_Date` or greater than `_Max_Date`. The `||` operator represents logical OR in DAX¹. This should give you the desired output. Let me know if you need further assistance! 😊
- NilRPost Patron
your answer is correct and This is exactly what I need , but the result is not what I want.
- AnonymousNot applicable
Hi NilR ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a tables.
Table 2 = var _Max_Date = DATE(2023,08,31) VAR _ENR_DATE = EOMONTH(_Max_Date,-2)+1 return Filter('Table', [max_enr]> _Max_Date)Table 3 = var _Max_Date = DATE(2023,9,1) VAR _ENR_DATE = EOMONTH(_Max_Date,-3)+1 return Filter('Table', [max_enr] >= _ENR_DATE && [max_enr] <=_Max_Date)(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.