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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
kdixon5490
Helper III
Helper III

Dynamic filters on Tables

Currently I have a table called data_sale that has all my sales done and this table can get very large.   Here is what the Advance Editor under query has...
let
Source = Sql.Database("ORL-WKS-KDIXI01", "BOS_TRR_Prod_COA"),
dbo_DATA_Sale = Source{[Schema="dbo",Item="DATA_Sale"]}[Data]
in
dbo_DATA_Sale

 

 

I need to put a filter on the column fsaledate to be the last 3 months only  fsaledate >= (dateadd(mm, -3, getdate()).  

 

How do I do this?   I tried several things and I keep getting this...

Expression.Error: We cannot apply operator < to types Table and DateTime.
Details:
Operator=&lt;
Left=Table
Right=12/1/2016 12:00:00 AM

 

My advance editor looks like this when I get the error.   (BTW  I created another query that get the StartDate and I called it StartDate) 

 

let
Source = Sql.Database("ORL-WKS-KDIXI01", "BOS_TRR_Prod_COA"),
dbo_DATA_Sale = Source{[Schema="dbo",Item="DATA_Sale"]}[Data],
#"Filtered Rows" = Table.SelectRows(dbo_DATA_Sale, each [FSaleDate] > StartDate)
in
#"Filtered Rows"

 

 

Any Help would be appreciated.

2 ACCEPTED SOLUTIONS

if the column type is set to Date you should see date filters
Capture.PNG

formula generated is somthing like this:

= Table.SelectRows(#"Renamed Columns", each Date.IsInPreviousNMonths([MthDate], 3))

you would obviously adjust the names to your setup



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

ChrisMendoza
Resident Rockstar
Resident Rockstar

hello @kdixon5490,

 

Try Date.IsInPreviousNMonths( )

 

1.PNG






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

6 REPLIES 6
ChrisMendoza
Resident Rockstar
Resident Rockstar

hello @kdixon5490,

 

Try Date.IsInPreviousNMonths( )

 

1.PNG






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



FlaF
Helper I
Helper I

Hi,

In edit query, you can filter your data. You have to click on the column fsaledate and select only the last 3 months

 

Regards

How do I make it dynamic to always no matter what day I look at the report to always grab the last 3 months?   Today's last 3 months is different than next weeks last 3 months.   

 

I hope that makes sense.

Yes I understand and you're right. I haven't explain it very well. You can enter in edit query mode and click on your column, then you can find the voice "date filters" in the drop-down menu of the column: "date filters" --> "Quarter" --> "Last quarter"

if the column type is set to Date you should see date filters
Capture.PNG

formula generated is somthing like this:

= Table.SelectRows(#"Renamed Columns", each Date.IsInPreviousNMonths([MthDate], 3))

you would obviously adjust the names to your setup



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Stachu
Community Champion
Community Champion

This should work:

= Table.SelectRows(dbo_DATA_Sale, each Date.IsInPreviousNMonths([[FSaleDate]], 3))


although the error indicates that you try to filter a table rather than a table column - when you filter [FSaleDate] manually for e.g. last month, how does the syntax look like?



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.