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
Easley06
Helper II
Helper II

Past 3 month excluding the current month.

I have scenario where I have to filter sales for last 3 months based on current Month.

Ex: If Selected Month is March which has maximum date 11th (11-Mar-2021) . I'll need to calculate for Last 3 months excluding current Month i.e. neet to get the vaule of Feb 2021 ,Jan 2021,Dec 2020.

 

current formula : 

P3  = (CALCULATE(SUM(FACT_OFF_TAKE[GROSS_AMT]), DATESINPERIOD(DATE_SYSTEM[DATE], LASTDATE(DATE_SYSTEM[DATE]), -3,MONTH),ALL(DATE_SYSTEM[MONTH_NAME],DATE_SYSTEM[MONTH],DATE_SYSTEM[YEAR])))/3
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Easley06 
Please try

P3 =
VAR CurrentDate =
    MAX ( DATE_SYSTEM[DATE] )
VAR EndDate =
    EOMONTH ( CurrentDate, - 1 )
VAR StartDate =
    EOMONTH ( CurrentDate, - 5 ) + 1
RETURN
    CALCULATE (
        SUM ( FACT_OFF_TAKE[GROSS_AMT] ),
        DATE_SYSTEM[DATE] >= StartDate,
        DATE_SYSTEM[DATE] <= EndDate,
        ALL ( DATE_SYSTEM[MONTH_NAME], DATE_SYSTEM[MONTH], DATE_SYSTEM[YEAR] )
    ) / 3

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

Hi @Easley06 
Please try

P3 =
VAR CurrentDate =
    MAX ( DATE_SYSTEM[DATE] )
VAR EndDate =
    EOMONTH ( CurrentDate, - 1 )
VAR StartDate =
    EOMONTH ( CurrentDate, - 5 ) + 1
RETURN
    CALCULATE (
        SUM ( FACT_OFF_TAKE[GROSS_AMT] ),
        DATE_SYSTEM[DATE] >= StartDate,
        DATE_SYSTEM[DATE] <= EndDate,
        ALL ( DATE_SYSTEM[MONTH_NAME], DATE_SYSTEM[MONTH], DATE_SYSTEM[YEAR] )
    ) / 3

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.