Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
NilR
Post Patron
Post Patron

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.

LOGIC: Date >= _ENR_DATE &&  Date <= _Max_date, but I encountered dates that are greater than VAR _Max_Date

 

 

 

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

NilR_0-1697141804796.png

 

 

1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

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.

vtangjiemsft_0-1698126281490.pngvtangjiemsft_1-1698126292755.png

 

 

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. 

View solution in original post

6 REPLIES 6
v-tangjie-msft
Community Support
Community Support

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.

vtangjiemsft_0-1698126281490.pngvtangjiemsft_1-1698126292755.png

 

 

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. 

parry2k
Super User
Super User

@NilR not the logic based on the DAX but what is your business logic? What you are trying to achieve?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@NilR what is the logic?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k 

Select Members who have been active in the latest two months.

Alef_Ricardo_
Resolver II
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! 😊

your answer is correct and This is exactly what I need , but the result is not what I want. 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.