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
Razorbx13
Post Patron
Post Patron

Setting a specific date filter whenever a Report is Run

I need to be able to run an report at anytime and run it with dates from the 18th of the previous month to the 19th the current month.  So if I run it on the 28th of September it would auto filter the report with dates between 8/18 and 9/19.  Would really be nice if I could run it on Oct 4th and since it is not yet Oct 20th it still uses those dates until 10/19 has passed but the first option would work for now. Any ideas?

1 ACCEPTED SOLUTION

Had to make a few changes but this got me in the right direction.  It works!  Thank you!

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Razorbx13 , You can have a column like

and use this This period as filter on report

new column =
var _day = day(today())
var _min = if(_day <20 , date(year(today()), month(today())-1,19) ,date(year(today()), month(today()),19))
var _max = if(_day <20 , date(year(today()), month(today())-2,18) ,date(year(today()), month(today())-1,18))

return
Switch( True ()
[date] >=_min && [Date] <_max , "This period",
"Others"
)

 

or a measure like

 

new measure =
var _day = day(today())
var _min = if(_day <20 , date(year(today()), month(today())-1,19) ,date(year(today()), month(today()),19))
var _max = if(_day <20 , date(year(today()), month(today())-2,18) ,date(year(today()), month(today())-1,18))

return
calculate([measure], filter(Table, Table[Date] <=_max and Table[Date] >=_min))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Had to make a few changes but this got me in the right direction.  It works!  Thank you!

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.