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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
chillpill
Helper II
Helper II

Calculating MAPE but only up to the last Date of Actuals

I have the below formula which works great for averaging the MAPE of multiple categories, however it messes up the result if I have a future date selected that does not include Actuals. How do I restrict the calculation to only the MAX date of Actuals/Forecast - in this case 4/1/2026 being only what I want to it calculate up to?

AvgMAPE = AVERAGEX(
    VALUES('Table'[Category]),
    CALCULATE(
        1 - ( ABS(SUM(Actuals) - SUM(Forecast)) / SUM(Actuals) )
    )
)

 

Date | Category | Actuals | Forecast | 
01/01/2026 | A1 | 100 | 400
01/01/2026 | A2 | 200 | 200
02/01/2026 | A1 | 300 | 400
02/01/2026 | A2 | 400 | 500
04/01/2026 | A1 | 500 | 100
04/01/2026 | A2 | 600 | 300
05/01/2026 | A1 |  400
05/01/2026 | A2 |  500
06/01/2026 | A1 |  100
06/01/2026 | A2 |  200
1 ACCEPTED SOLUTION
AmiraBedh
Super User
Super User

Hello !

Thank you for posting on MS Fabric community.

Try to use a cutoff date inside the measure then force the calculation to only evaluate rows up to that date.

If your future rows have blank actuals.

With your sample, it should stop at 04/01/2026 and ignore 05/01/2026 and 06/01/2026.

AvgMAPE =
VAR LastActualDate =
CALCULATE(
MAX('Table'[Date]),
FILTER(
ALLSELECTED('Table'),
NOT ISBLANK('Table'[Actuals])
)
)
VAR CurrentRowDate =
MAX('Table'[Date])
RETURN
IF(
CurrentRowDate > LastActualDate,
BLANK(),
AVERAGEX(
VALUES('Table'[Category]),
CALCULATE(
1 - DIVIDE(
ABS(SUM('Table'[Actuals]) - SUM('Table'[Forecast])),
SUM('Table'[Actuals])
),
FILTER(
ALLSELECTED('Table'[Date]),
'Table'[Date] <= LastActualDate
)
)
)
)
 
AmiraBedh_0-1776795437110.png

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

View solution in original post

10 REPLIES 10
v-echaithra
Community Support
Community Support

Hi @chillpill ,

We’d like to follow up regarding the recent concern. Kindly confirm whether the issue has been resolved, or if further assistance is still required. We are available to support you and are committed to helping you reach a resolution.

Thank you.

v-echaithra
Community Support
Community Support

Hi @chillpill ,

Thank you for reaching out to Microsoft Community.
Please check the below PBIX file.

Hope this helps.

AmiraBedh
Super User
Super User

Hello !

Thank you for posting on MS Fabric community.

Try to use a cutoff date inside the measure then force the calculation to only evaluate rows up to that date.

If your future rows have blank actuals.

With your sample, it should stop at 04/01/2026 and ignore 05/01/2026 and 06/01/2026.

AvgMAPE =
VAR LastActualDate =
CALCULATE(
MAX('Table'[Date]),
FILTER(
ALLSELECTED('Table'),
NOT ISBLANK('Table'[Actuals])
)
)
VAR CurrentRowDate =
MAX('Table'[Date])
RETURN
IF(
CurrentRowDate > LastActualDate,
BLANK(),
AVERAGEX(
VALUES('Table'[Category]),
CALCULATE(
1 - DIVIDE(
ABS(SUM('Table'[Actuals]) - SUM('Table'[Forecast])),
SUM('Table'[Actuals])
),
FILTER(
ALLSELECTED('Table'[Date]),
'Table'[Date] <= LastActualDate
)
)
)
)
 
AmiraBedh_0-1776795437110.png

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

This is a great solution and I follow what's happening, and it works if I only select dates where Actuals exist. If I select all dates available it doesn't provide a value, whereas I am hoping despite what month I choose it will calculate a value. For example:

 

1. If I select 1/1, 2/1, 3/1, and 4/1 from the date filter I want it to result in the avg MAPE for dates 1/2 - 3/1. 

2. If I select 1/2 - 2/1 it provides the avg MAPE for those two dates

Hi,

Your question is not clear.  If you select jan-Apr, why should data for April be excluded.  There is Actual data for April.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Apologies - you are right. I meant to say, to be clear, that if I choose a series of dates and that series includes a date that does not have Actuals then it should still calculate the avg mape for all dates in the series that do have actuals. 

 

Example: I select dates 1/1 - 6/1, but only 1/1 - 4/1 have actuals. I would need it to still calculate/return the avg MAPE for 1/1 - 4/1

Does this measure work?

AvgMAPE = AVERAGEX(FILTER(VALUES('Table'[Category]),SUM(Actuals)>0),CALCULATE(1 - ( ABS(SUM(Actuals) - SUM(Forecast)) / SUM(Actuals) )))

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you! This works when I select all months with Actuals, ie 1/1 - 4/1, but as soon as I include a date that does not have actuals yet, ie 5/1, the average starts decreasing. I was hoping it would calculate the avg MAPE for only months that have actuals, regardless if a month without Actuals is selected. 

Hi,

Please share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
dedelman_clng
Community Champion
Community Champion

@chillpill there are multiple ways you can handle this, depending on the use case and specifics about the data set

 

some examples: 

AvgMAPE = IF(ISBLANK(SUM(Actuals)), BLANK(), [remainder of your measure])

AvgMAPE = IF(SUM([Actuals]) = 0, BLANK(), [remainder of your measure])

AvgMAPE = IF(SELECTEDVALUE([Date]) > TODAY(), BLANK(), [remainder of your measure])

Hope this helps

David

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.