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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Limiting value filter to certain date range

I need to exclude certain values, but only after a certain date range. I cannot figure out how to do this in M. What I am trying to accomplish basically looks like this:

 

Table.SelectRows(#Table, if [Date] > xx/xx/xxxx then each [Item] <> "Excluded Value")

 

What is tripping me up here is the if statement requires an else and I don't know what to put there. Another way to do it I guess would be to append an unfiltered table before the date and a filtered one after, but I want to see if I can do it in one line of code.

1 ACCEPTED SOLUTION
TheoC
Super User
Super User

Hi @Anonymous 

 

You can add a custom column and use the following:

 

if Date.IsAfter( [Date] , #date ( 2023 , 1 , 1 ) ) or not List.Contains ( {"Excluded Value"} , [Item] ) then "Keep" else "Exclude"

 

Just change the date based on YYYY , MM , DD values. 

 

Hopefully this helps.

 

Theo 

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

View solution in original post

3 REPLIES 3
TheoC
Super User
Super User

Hi @Anonymous 

 

You can add a custom column and use the following:

 

if Date.IsAfter( [Date] , #date ( 2023 , 1 , 1 ) ) or not List.Contains ( {"Excluded Value"} , [Item] ) then "Keep" else "Exclude"

 

Just change the date based on YYYY , MM , DD values. 

 

Hopefully this helps.

 

Theo 

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Anonymous
Not applicable

Thanks, I wound up creating 2 sub queries and appending them.

@Anonymous that is good you achieved your outcome!

If you're working with large amounts of data / records, just be conscious that creating two sub queries and then appending them is probably not the most effective approach to apply.  Although it can achieve what needs to quite easily with smaller datasets, etc., as you expand and grow the size and complexity of your data model, it is far more likely to cause inefficiencies and other complications.  

All the best in your BI journey and thank you for letting providing an update on the post.  

If you're content with any of the responses, including your own, please feel free to accept a solution and close the post.

 

All the best.


Theo

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors