Power Query Date Column filtering greater than or equal to date in Excel cell

GRCArizona

Board Regular
Joined
Apr 24, 2010
Messages
95
Hi - I've relatively new to Power Query and I can't seem to find out how to accomplish this. I've got a date in a cell (start of our Fiscal Year). I'm trying to filter a column of data in Power Query that is greater than or equal to the Fiscal Year date in the excel cell. I've created a table in excel with the Fiscal Date and brought it over to Power Query ("tbl_Start_Date"). My M Code is:

=Table.SelectRows(#"Expanded Table Column1", each [Policy Start Date] >=(tbl_Start_Date))

but I'm getting an Expression.Error: We cannot apply operator < to types DateTime and Date.

It works perfect if I only use "=" and get rid of the greater than portion.

I've searched for about an hour now and can't seem to find where anyone else has asked this.

Any help is greatly appreciated!

thanks
GRC
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
You can do a helper column that is just equal to the fiscal date. Then it's a conditional column that compares the two (make sure they have the same data type).
 
Upvote 0
That worked! Thanks! Just surprised it isn't easier (as far as I can tell...) to use >=.

Seems like the more I learn this stuff, I realize I don't know very much...

Thanks again!
 
Upvote 0
The error message simply points out you cannot compare fields of type datetime with fields of type date. Both fields should be the same.
Then the set-up will work. No need to duplicate anything. As a rule of thumb never add columns to PQ if you can avoid it as it makes it run slower. At least that is my experience.

Power Query:
Table.SelectRows(#"Expanded Table Column1", each DateTime.Date([Policy Start Date]) >=tbl_Start_Date )
or
Power Query:
Table.SelectRows(#"Expanded Table Column1", each [Policy Start Date] >=DateTime.Date( tbl_Start_Date) )

depending on which field is actually a datetime field.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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