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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jcambareri
Frequent Visitor

Filter dates from the 27th day of the previous month until now

I'm trying to create a filter in power query that will show me only items that are created on or after the 27th day of the previous month until "today".

 

For example, today is July 26th. The query would show me only items created from June 27th 

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @jcambareri 

 

You have a date column you can filter, right? Here is one way, provide sample data in a format which people can copy in the future

 

Vera_33_0-1627276269598.png

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bdJLCgMxDATRu3g9MFLL37MMs0hy/zvEziY4lW3BA0HrutIjHcnHafWUydN9XOk5k2xLr5V8SwtKhEGYCQthJWyEnXAAhgHavL7t0LSlBS229IGZsBBWwkbYCQegG6A7oIswCDNhIayEjbATDkAZoBxQIgzCTFgIK2Ej7IQDMAww/nzOTP1nR33T/QY=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Item = _t, Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Item", type text}, {"Date", type date}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each 
[Date] >= Date.AddDays( Date.AddMonths( Date.StartOfMonth(Date.From( DateTime.LocalNow())),-1),26) 
and 
[Date] <= Date.From( DateTime.LocalNow()))
in
    #"Filtered Rows"

 

 

View solution in original post

2 REPLIES 2
mussaenda
Super User
Super User

Hi @jcambareri,

 

Assuming you have a Date column and the data type is Date,

You can do the filtering and select last month. 

It will automatically filter your data for the past 1 month.

Untitled.png 

 

Hope this idea helps.

Vera_33
Resident Rockstar
Resident Rockstar

Hi @jcambareri 

 

You have a date column you can filter, right? Here is one way, provide sample data in a format which people can copy in the future

 

Vera_33_0-1627276269598.png

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bdJLCgMxDATRu3g9MFLL37MMs0hy/zvEziY4lW3BA0HrutIjHcnHafWUydN9XOk5k2xLr5V8SwtKhEGYCQthJWyEnXAAhgHavL7t0LSlBS229IGZsBBWwkbYCQegG6A7oIswCDNhIayEjbATDkAZoBxQIgzCTFgIK2Ej7IQDMAww/nzOTP1nR33T/QY=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Item = _t, Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Item", type text}, {"Date", type date}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each 
[Date] >= Date.AddDays( Date.AddMonths( Date.StartOfMonth(Date.From( DateTime.LocalNow())),-1),26) 
and 
[Date] <= Date.From( DateTime.LocalNow()))
in
    #"Filtered Rows"

 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors