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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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