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
niko18033
Helper I
Helper I

Filter to latest 12 calendar months, excluding latest 2 months

I'm trying to filter to the last 12 full months of data, excluding the last 2. While the default relative date last 12 calendar months does limit to the last complete calendar month, I'd like to exclude that month as well. Current Output is able to do Jun 2020 - Jul 2021 (relative date filter: latest 13 calendar months)

 

Assuming the date is Aug 26, 2021 (or any date in Aug): this should be the desired output for the column: Jul 2020 - Jun 2021

 

Jul 2020

Aug 2020
Sep 2020
Oct 2020
Nov 2020
Dec 2020
Jan 2021
Feb 2021
Mar 2021
Apr 2021
May 2021
June 2021

 

Here's the column I have so far, but it's not working:

Calendar exc Latest 2 Months =
DATESBETWEEN(Table[Month Field],
DATEADD(LASTDATE(Table[Month Field]), -13, MONTH),
DATEADD(LASTDATE(Table[Month Field]), -2, MONTH))
 
Here's the error message I receive: A table of multiple values was supplied where a single value was expected.
Month Field is an aggregation of my date field (new group, bin size = 1 month).
 
Any assistance would be much appreciated!
1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@niko18033 

Here are the steps you can follow:

1. Create calculated table.

Calendar =
CALENDAR(DATE(2020,1,1),DATE(2021,12,30))

2. Create measure.

Measure =
IF(
    MAX('Calendar'[Date])>=DATE(YEAR(TODAY())-1,MONTH(TODAY())-1,1)&&MAX('Calendar'[Date])<=EOMONTH(TODAY(),-2),1,0)

3. Place the measure in Filters, set is =1, apply.

Vpazhenmsft_2-1630314779785.png

4. Result:

Shown is July 2020-June 2021

Vpazhenmsft_3-1630314806982.png

 

Best Regards,

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

2 REPLIES 2
V-pazhen-msft
Community Support
Community Support

@niko18033 

Here are the steps you can follow:

1. Create calculated table.

Calendar =
CALENDAR(DATE(2020,1,1),DATE(2021,12,30))

2. Create measure.

Measure =
IF(
    MAX('Calendar'[Date])>=DATE(YEAR(TODAY())-1,MONTH(TODAY())-1,1)&&MAX('Calendar'[Date])<=EOMONTH(TODAY(),-2),1,0)

3. Place the measure in Filters, set is =1, apply.

Vpazhenmsft_2-1630314779785.png

4. Result:

Shown is July 2020-June 2021

Vpazhenmsft_3-1630314806982.png

 

Best Regards,

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

PaulDBrown
Community Champion
Community Champion

this thread might help:

https://community.powerbi.com/t5/Desktop/Last-12-Months-of-Running-Total-Measure/m-p/2040639#M764481 

 

or this alternative method (though the explanation is in Spanish 

 

https://community.powerbi.com/t5/Desktop/MOSTRAR-valores-HASTA-EL-MES-FILTRADO-Mostrar-SUMA-de-venta... 

 

or if those aren't helpful, please post sample data or a sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






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! Prices go up Feb. 11th.

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.

Jan NL Carousel

Fabric Community Update - January 2025

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