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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
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.