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

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
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,224,875
Messages
6,181,514
Members
453,050
Latest member
Obil

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