Power Query to filter less than today

harishs

Board Regular
Joined
Jul 3, 2016
Messages
50
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Experts,

Looking for a solution to filter down list of emplyoees less than today date.


Code:
=Table.SelectRows (#"Filtered Rows", each [Last Day Worked] < DateTime.Localnow())

The code above gives me an error, Expression.error: We cannot apply operator < to types DateTime and Date.

Last Day Worked is a column with Dates.

Regards,
Harish S
 
Last edited:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    [COLOR="#FF0000"][B]#"Changed Type"[/B][/COLOR] = Table.TransformColumnTypes(Source,{{"Date", type datetime}, {"ID", type text}, {"Name", type text}, {"Company", type text}, {"Country", type text}, {"City", type text}, {"Sales", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows([COLOR="#FF0000"][B]#"Changed Type"[/B][/COLOR], each [Date] < DateTime.LocalNow())
in
    #"Filtered Rows"
maybe try Previous Step not the same

better if you post whole code not a small part of it
 
Last edited:
Upvote 0
Would this work?
= Table.SelectRows(#"Filtered Rows", each [Last Day Worked] < DateTime.Date(DateTime.LocalNow()))

Note capital N in Localnow. The code converts DateTime to Date only
Peter
 
Upvote 0
Solution
Thanks Peter & sandy666.

Both the codes are working fine, however i am going with Peter's code.

Regards,
Harish S
 
Upvote 0

Forum statistics

Threads
1,223,939
Messages
6,175,530
Members
452,651
Latest member
wordsearch

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top