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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
emilyrichardson
Frequent Visitor

Monthly prediction based on a rolling monthly average

I currently have the below formula that is working out the rolling avg month on month. Which is then used to minus the rolling average from the last calendar month to give me a predicition for what I should expect for the current month. The only issue is that at the beginning of every month I am having to go in and update the formula to include the last calendar month. Is there a way to update this formula so I am not having to update it, happy for the formulas to be seperated if that is easier?

 

New Prod Control forecast P16s =

VAR NovemberAvg =
    CALCULATE(
        SUM(Table[Score]) / DISTINCTCOUNT(Table[ProdNumber]),
        FILTER(
            'Table',
            'Table[CreditDate] >= DATE(2024, 11, 01) &&
            'Table'[CreditDate] <= DATE(2024, 11, 30) &&
            'Table'[ID] = "Mfg Control"
        )
    )

VAR OctoberAvg =
    CALCULATE(
        SUM('Table'[Score]) / DISTINCTCOUNT('Table'[ProdNumber]),
        FILTER(
            'Table',
            'Table'[CreditDate] >= DATE(2024, 10, 01) &&
            'Table'[CreditDate] <= DATE(2024, 10, 31) &&
            'Table'[ID] = "Mfg Control"
        )
    )

-- Calculate the average score for the last month (September)
VAR SeptemberAvg =
    CALCULATE(
        SUM('Table'[Score]) / DISTINCTCOUNT('Table'[ProdNumber]),
        FILTER(
            'Table',
            'Table'[CreditDate] >= DATE(2024, 09, 01) &&
            'Table'[CreditDate] <= DATE(2024, 09, 30) &&
            'Table'[ID] = "Mfg Control"
        )
    )

-- Calculate average scores for previous months with the "Mfg Control" filter
VAR MarchAvg =
    CALCULATE(
        SUM('Table'[Score]) / DISTINCTCOUNT('Table'[ProdNumber]),
        FILTER(
            'Table',
            'Table'[CreditDate] >= DATE(2024, 03, 01) &&
            'Table'[CreditDate] <= DATE(2024, 03, 31) &&
            'Table'[ID] = "Mfg Control"
        )
    )

VAR AprilAvg =
    CALCULATE(
        SUM('Table'[Score]) / DISTINCTCOUNT('Table'[ProdNumber]),
        FILTER(
            'Table',
            'Table'[CreditDate] >= DATE(2024, 04, 01) &&
            'Table'[CreditDate] <= DATE(2024, 04, 30) &&
            'Table'[ID] = "Mfg Control"
        )
    )

VAR MayAvg =
    CALCULATE(
        SUM('Table'[Score]) / DISTINCTCOUNT('Table'[ProdNumber]),
        FILTER(
            'Table',
            'Table'[CreditDate] >= DATE(2024, 05, 01) &&
            'Table'[CreditDate] <= DATE(2024, 05, 31) &&
            'Table'[ID] = "Mfg Control"
        )
    )

VAR JuneAvg =
    CALCULATE(
        SUM('Table'[Score]) / DISTINCTCOUNT('Table'[ProdNumber]),
        FILTER(
            'Table',
            'Table'[CreditDate] >= DATE(2024, 06, 01) &&
            'Table'[CreditDate] <= DATE(2024, 06, 30) &&
            'Table'[ID] = "Mfg Control"
        )
    )

VAR JulyAvg =
    CALCULATE(
        SUM('Table'[Score]) / DISTINCTCOUNT('Table'[ProdNumber]),
        FILTER(
            'Table',
            'Table'[CreditDate] >= DATE(2024, 07, 01) &&
            'Table'[CreditDate] <= DATE(2024, 07, 31) &&
            'Table'[ID] = "Mfg Control"
        )
    )

VAR AugustAvg =
    CALCULATE(
        SUM('Table'[MPAScore]) / DISTINCTCOUNT('Table'[ProdNumber]),
        FILTER(
            'Table',
            'Table'[CreditDate] >= DATE(2024, 08, 01) &&
            'Table'[CreditDate] <= DATE(2024, 08, 31) &&
            'Table'[ID] = "Mfg Control"
        )
    )

-- Calculate the month-on-month differences
VAR MarchToAprilDiff = AprilAvg - MarchAvg
VAR AprilToMayDiff = MayAvg - AprilAvg
VAR MayToJuneDiff = JuneAvg - MayAvg
VAR JuneToJulyDiff = JulyAvg - JuneAvg
VAR JulyToAugustDiff = AugustAvg - JulyAvg
VAR AugustToSeptemberDiff = SeptemberAvg - AugustAvg
VAR SeptembertoOctoberDiff = OctoberAvg - SeptemberAvg
VAR OctobertoNovemberDiff = NovemberAvg - OctoberAvg

-- Calculate the average of the month-on-month differences
VAR AvgMonthlyDiff =
    (MarchToAprilDiff + AprilToMayDiff + MayToJuneDiff + JuneToJulyDiff + JulyToAugustDiff + AugustToSeptemberDiff + SeptembertoOctoberDiff + OctobertoNovemberDiff) / 8

-- Return the September average minus the average of the month-on-month differences
RETURN
    NovemberAvg - AvgMonthlyDiff
1 REPLY 1
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Users online (27)