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?
Thanks in advance.
Dummy data is in the drive for download.
https://drive.google.com/drive/folders/1eejhJ_zFyWfpGz2SS9iu6WnQIlfFLpQr?usp=sharing
@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 =
ADDCOLUMNS (
__table,
"@Historical", CALCULATE ( SUM ( 'Fact Current Data'[History] ) ),
"@Forecast", CALCULATE ( SUM ( 'Fact Historical Data'[Forecast] ) )
)
RETURN
SUMX ( __data, ABS ( [@Historical] - [@Forecast] ) )
✨ Follow us on LinkedIn
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.⚡
Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
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
@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 ) )
✨ Follow us on LinkedIn
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.⚡
Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
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
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!
User | Count |
---|---|
209 | |
70 | |
68 | |
57 | |
57 |
User | Count |
---|---|
251 | |
217 | |
104 | |
76 | |
71 |