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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
cb_wcc
New Member

Date filter last 3 months

Hi there!

 

I'm trying to filter for data that is from the last 3 months.  Currently I'm using the filter below and adjusting the date each week to be 3 months ago (ie today is Sept 6, 2024 so I adjust the date to be June 6, 2024) but this is a pain to keep adjusting and I wondered what would be a better way?  Here's the filter I'm currently using...could I alter this filter in some way?

 

= Table.SelectRows(#"Expanded std_case_service_file_individuals", each [event_start_timestamp] > #datetime(2024, 6, 9, 0, 0, 0))

 

 

2 ACCEPTED SOLUTIONS
Ahmedx
Super User
Super User

or try this

= Table.SelectRows(#"Expanded std_case_service_file_individuals", each [event_start_timestamp] >= Date.AddMonths( Date.From(DateTime.LocalNow()),-3))

View solution in original post

Anonymous
Not applicable

Hi @cb_wcc ,
You can try this 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XdMxjsMwEEPRu6RewB5KNO2zBLn/NRbbLPhTstLHPOj9fu1jDp3ar8/P31CP1WP3cI+rR3rcPZ4ec2KhYRAxqBhkDDoGIYOSQcqgRWgR74EWoUVoEVqEFqFFaBFaVrW4adw0bho3jZvGTeOmcdO4aQwag8agMWgMGoPGoDFoDBqDxqAxaAwag8agMWgMGoPGoDFo/EWzquU6MNRj9dg93OPqkR53jwePnlgMQsSgYpAx6BiEDEoGKYMWoUW8B1qEFqFFaBFahBahRWhpqDRNmiZNk6ZJ06Rp0jRpmjRNQBPQBDQBTUAT0AQ0AU1AE9AENAFNQBPQBDQBTUAT0AQ0AU2+aPoP3QeGeqweu4d7XD3S4+7x4NETi0GIGFQMMgYdg5BBySBl0CK0iPdAi9AitAgtQovQIrQILQstDfUcGOqxeuwe7nH1SI+7x4NHTywGIWJQMcgYdAxC/qE+vw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
    FilteredRows = Table.SelectRows(Source, each Date.From([Date]) > Date.AddMonths(Date.From(DateTime.LocalNow()), -3))
in
    FilteredRows

Final output

vheqmsft_0-1725864560907.png

Best regards,
Albert He


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

View solution in original post

4 REPLIES 4
Ahmedx
Super User
Super User

or try this

= Table.SelectRows(#"Expanded std_case_service_file_individuals", each [event_start_timestamp] >= Date.AddMonths( Date.From(DateTime.LocalNow()),-3))
Ahmedx
Super User
Super User

pls try this

 

 

= Table.SelectRows(#"Expanded std_case_service_file_individuals", each Date.IsInPreviousNMonths([event_start_timestamp], 3))

 

 

Thanks so much!! This did filter for the previous 3 months but was including all of June, so I modified the query as follows to show the last 90 days (approx 3 months) and it works!!

 

= Table.SelectRows(#"Expanded std_case_service_file_individuals", each Date.IsInPreviousNDays([event_start_timestamp], 90))

 

Not sure if there's another way to filter to exactly 3 months from the current date, but if not, 90 days works for me. 🙂 

 

I did try your other suggestion as well but I got this error:

 

Expression.Error: We cannot apply operator < to types Date and DateTime.
Details:
Operator=<
Left=6/06/24
Right=1/17/05 3:00:00 PM

Anonymous
Not applicable

Hi @cb_wcc ,
You can try this 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XdMxjsMwEEPRu6RewB5KNO2zBLn/NRbbLPhTstLHPOj9fu1jDp3ar8/P31CP1WP3cI+rR3rcPZ4ec2KhYRAxqBhkDDoGIYOSQcqgRWgR74EWoUVoEVqEFqFFaBFaVrW4adw0bho3jZvGTeOmcdO4aQwag8agMWgMGoPGoDFoDBqDxqAxaAwag8agMWgMGoPGoDFo/EWzquU6MNRj9dg93OPqkR53jwePnlgMQsSgYpAx6BiEDEoGKYMWoUW8B1qEFqFFaBFahBahRWhpqDRNmiZNk6ZJ06Rp0jRpmjRNQBPQBDQBTUAT0AQ0AU1AE9AENAFNQBPQBDQBTUAT0AQ0AU2+aPoP3QeGeqweu4d7XD3S4+7x4NETi0GIGFQMMgYdg5BBySBl0CK0iPdAi9AitAgtQovQIrQILQstDfUcGOqxeuwe7nH1SI+7x4NHTywGIWJQMcgYdAxC/qE+vw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
    FilteredRows = Table.SelectRows(Source, each Date.From([Date]) > Date.AddMonths(Date.From(DateTime.LocalNow()), -3))
in
    FilteredRows

Final output

vheqmsft_0-1725864560907.png

Best regards,
Albert He


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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.

Top Kudoed Authors