Skip to main content
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
DAMyers
New Member

Power Query Excel filter rows using start and end date from cell values in spreadsheet

I have a power query from SQL database to an Excel workbook. I need to filter the query rows using a start and end date from cells in the workbooks. I created the cells with values 5/1/2025 for start date and 5/31/2025 for end date. I then selected the start date cells and selected and created a query using Data==>Get Data from Table/Range. This created a Power Query named StartDate. I did the same for EndDate value resulting in query End date.

DAMyers_0-1747757680970.pngDAMyers_1-1747757744055.png

 

 

 

I am attempting to filter rows in my main query using these two query values. When I alter the main query filter rows code like this:

= Table.SelectRows(#"Filtered Rows3", each [SAMPLED_DATE] >= StartDate and [SAMPLED_DATE] <= EndDate)

DAMyers_2-1747757900143.png

 

I get this error:

Expression.Error: We cannot apply operator < to types Table and DateTime.
Details:
Operator=<
Left=[Table]
Right=5/8/2025 11:02:25 AM

 

I have checked and the data type for [SAMPLED_DATE], StartDate, and EndDate are all Date/Time. What am I missing?

1 ACCEPTED SOLUTION
jgeddes
Super User
Super User

It looks like your 'Start Date' and 'End Date' references are tables. You may want to look at using Table.FirstValue(). Something like the following might work for you.

Table.SelectRows(#"Filtered Rows3", each [SAMPLED_DATE] >= Table.FirstValue(StartDate) and [SAMPLED_DATE] <= Table.FirstValue(EndDate))

  





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

1 REPLY 1
jgeddes
Super User
Super User

It looks like your 'Start Date' and 'End Date' references are tables. You may want to look at using Table.FirstValue(). Something like the following might work for you.

Table.SelectRows(#"Filtered Rows3", each [SAMPLED_DATE] >= Table.FirstValue(StartDate) and [SAMPLED_DATE] <= Table.FirstValue(EndDate))

  





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon โ€“ Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save โ‚ฌ200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors