Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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.
Solved! Go to Solution.
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
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
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
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 7 | |
| 6 |