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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

How to filter dates since last 2 calendar months including current month?

Hello,

 

I have a table with multiple columns, including, dates. I am trying to make a dynamic filter for the table visualization in Power BI, so that it will only show the data since the last 2 calendar months (starting from the first day of the month, 2 months ago) until the current month. So, in this case, as from 1 December 2021 until 28 February 2022.

 

I am thinking maybe do it in DAX? I don't know how to proceed. Any help is much appreciated!

 

DateAmountCountry
01/11/202144China
06/11/202144Germany
01/12/202148Indonesia
19/12/202150Kuwait
21/01/20223France
23/01/20223India
03/01/20221Indonesia
11/02/20226Brazil
13/01/20222Germany
14/02/20227Mexico
21/03/202212Poland
1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@Anonymous 

Add a column to your calendar table like this.

Month Offset = DATEDIFF ( TODAY(), Dates[Date], MONTH )

Then you can set a filter on that column for <= 0 and >= -2 and that will give you the last 2 full months and the current month.

View solution in original post

2 REPLIES 2
phbronson
Frequent Visitor

Another simple solution is to use the "Date/Time Filters"

filter_past_2months.png

jdbuchanan71
Super User
Super User

@Anonymous 

Add a column to your calendar table like this.

Month Offset = DATEDIFF ( TODAY(), Dates[Date], MONTH )

Then you can set a filter on that column for <= 0 and >= -2 and that will give you the last 2 full months and the current month.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Users online (417)