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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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