cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper IV

## Calculate Mean Absolute Error using columns from 4 tables

Hi guys,

I've been trying to calculate the MAE but I am having some problems. I think the solution could have something to do with the summarize function but I am not sure how to use it here.

MAE  = abs (actuals - forecast ) / number of observations

With my current formula, I am summing all the actuals per subsidiary, then summing all the actuals per forecast and calculating the difference. However, I would like to calculate this difference per month. Then, only in the end, to aggregate per subsidiary.

I also tried to use SUMX but it did not work. I think i need to create some temporary table with summarize in order to get the correct results. Can you please help me?

4 REPLIES 4
Super User

@jessicarocha Hey sorry, I saw your file afterward and I realized that columns are in different fact tables.

Try this measure:

``````Measure New =
VAR __table =
CROSSJOIN (
CALCULATETABLE(VALUES ( 'Dim Subsidiary'[Subsidiary] ), 'Fact Current Data' ),
CALCULATETABLE( VALUES ( 'Dim Date'[Date] ), 'Fact Current Data' )
)
VAR __data =
__table,
"@Historical", CALCULATE ( SUM ( 'Fact Current Data'[History] ) ),
"@Forecast", CALCULATE ( SUM ( 'Fact Historical Data'[Forecast] ) )
)
RETURN
SUMX ( __data, ABS ( [@Historical] - [@Forecast] ) )
``````

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤

Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helper IV

Hi @parry2k . Thank you so much for the help! Sorry for the delayed answer, I was sick.

So, your measure solved a part of my problem. It calculates the Absolute Percentage Error (APE) per Subsidiary and month correctly. But when I aggregate per subsidiary, something is wrong....
In addition, I would like to calculate the Mean absolute percentage error(MAPE). Basically just the APE divided by the number of observations (N). In this case, 3.

I think the number of observations I was able to get it right with this measure:

``````Test N =

Calculate(
DISTINCTCOUNT('Dim Date'[Year Month]),

FILTER(
'Fact Historical Data','Fact Historical Data'[Forecast done in]= min('Fact Historical Data'[Forecast done in])
),
FILTER('Dim Date', 'Dim Date'[Fiscal Year] = "2021/22"),
FILTER('Fact Current Data', 'Fact Current Data'[History] <> BLANK())
)``````

So it is just missing the aggregation of your metric to be correct by subsidiary. Can you help me with that?

Thank you so much!

Kind regards, Jéssica

Super User

@jessicarocha maybe add a different column first and then sum it up:

``````Difference Column = Table[History] - Table[Forecast]

Difference Measure = SUM ( Table[Difference Column] )

Avg = DIVIDE ( [Difference Measure], COUNTROWS ( Table ) ) ``````

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤

Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helper IV

Thanks for the answer @parry2k. How can I create this column since the two variables are in different tables?
I thought about a calculated column but it is not working. My two variables are in different fact tables that are not direct connected to each other. But they could be connected using the Dim Subsidiary and Dim Date....

Thanks.

Greetings, Jéssica

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

#### Fabric Community Update - August 2024

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

Top Solution Authors
Top Kudoed Authors