The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I am trying to create a date filter to exclude items where the date is greater than today - 150 days.
Based on some research, I have come up with the below; however, it is excluding Today!
Any help would be greatly appreciated
= Table.SelectRows(#"Sorted Rows", each Date.IsInPreviousNDays([Finish Date], 150) or Date.IsInNextNDays([Finish Date], 1000))
Solved! Go to Solution.
I'm a bit confused. You want to exclude rows wheer the date is greater than today -150? But your code keeps those rows?
Your code will exclude today because today falls inside yoru exclusion criteria. Today's date is greater than today - 150 days.
To keep rows where the date is greater than today -150
= Table.SelectRows(#"Sorted Rows", each Date.IsInPreviousNDays([Finish Date], 150) or [Finish Date] = Date.From(DateTime.LocalNow()))
To exclude these rows
= Table.SelectRows(#"Sorted Rows", each not (Date.IsInPreviousNDays([Finish Date], 150) or [Finish Date] = Date.From(DateTime.LocalNow())))
Phil
Proud to be a Super User!
Hi Phil,
Yes - apologies for my clumsiness - I was trying to exclude items that were less than today -150, i.e. only show items that had a date greater than today - 150 days.
Your code helped me, but for some reason excluded items after today. I adapted your code and to the below and now have the result I need.
Thanks for the help
= Table.SelectRows(#"Sorted Rows", each Date.IsInPreviousNDays([Finish Date], 150) or [Finish Date] = Date.From(DateTime.LocalNow()) or Date.IsInNextNDays([Finish Date], 900000) )
Hi Phil,
Yes - apologies for my clumsiness - I was trying to exclude items that were less than today -150, i.e. only show items that had a date greater than today - 150 days.
Your code helped me, but for some reason excluded items after today. I adapted your code and to the below and now have the result I need.
Thanks for the help
= Table.SelectRows(#"Sorted Rows", each Date.IsInPreviousNDays([Finish Date], 150) or [Finish Date] = Date.From(DateTime.LocalNow()) or Date.IsInNextNDays([Finish Date], 900000) )
I'm a bit confused. You want to exclude rows wheer the date is greater than today -150? But your code keeps those rows?
Your code will exclude today because today falls inside yoru exclusion criteria. Today's date is greater than today - 150 days.
To keep rows where the date is greater than today -150
= Table.SelectRows(#"Sorted Rows", each Date.IsInPreviousNDays([Finish Date], 150) or [Finish Date] = Date.From(DateTime.LocalNow()))
To exclude these rows
= Table.SelectRows(#"Sorted Rows", each not (Date.IsInPreviousNDays([Finish Date], 150) or [Finish Date] = Date.From(DateTime.LocalNow())))
Phil
Proud to be a Super User!