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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.