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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Chava1881
Helper II
Helper II

Aggregation measure - is locking an aggretation level an option?

Hello, 

I am new to my company and I was given the task to create a report with Forecast Error and MAPE %, this calculation must be at the category level. Formulas are below for a better understanding of the issue:

FCST ERROR: abs(Orders-FCST)

MAPE %: Sum of error/Orders

 

Issue: My measure calculates each individual category perfectly; however, as data aggregates, the error gets reduced because it is going up in the hierarchy, for example:

 

if I want to see the World Wide, the measure uses the total FCST and Total Orders to make both calculations, hence, the error is reduced significantly when comparing vs the category breakdown, as I go up in the hierarchy, the less error there is. that's why I was wondering if a measure can be tied to a column (Category column in this case), so when the number is rolled up to World Wide the error and MAPE are tied to the sum of Forecast, Orders, and forecast error.

 

The reason I don't use a calculated column for the error is that it locks the error at the sub-region level so when you sum the error, it increases and pushes the MAPE to higher numbers. 

 

See samples of what I want to achieve below and what I am getting.

 

What I need to achieve: 

Chava1881_0-1638997517768.png

 

 

What I get:

Blue: Error calculated by calculated column then MAPE using a measure with this calculated column

Green: MEASURE calculating everything. 

Chava1881_1-1638996199694.png

Chava1881_2-1638996329810.png

Chava1881_3-1638996501792.png

Green Measure below:

 

 

MAPE_Agg_Measure = 
VAR TOTAL_FCST = CALCULATE(
                            SUM('Aggregated-Data'[Forecast])
)

VAR TOTAL_ORDERS_RSD = Calculate(
                                sum('Aggregated-Data'[Orders])
)

VAR FCST_Error = abs( TOTAL_ORDERS_RSD - TOTAL_FCST )

Return
FCST_Error/TOTAL_ORDERS_RSD

 

 

my question is:

Is there a way I can do this calculation but limit them by category, telling DAX that it needs to aggregate by category and from there it can roll up? - I know this can be done in QlikSense as you can set a column to aggregate calculations- or else am I taking the wrong route here? any thoughts. 

PBIX is attached. 

 

Click Download to get it 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Chava1881 this measure will give you correct Error sum and then you can further add measure to us this Error measure

 

Error = 
SUMX ( 
    VALUES ( 'Aggregated-Data'[Category] ), 
    ABS ( 
        CALCULATE ( SUM ( 'Aggregated-Data'[ORDERS] ) )-
        CALCULATE ( SUM ( 'Aggregated-Data'[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.



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.

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@Chava1881 this measure will give you correct Error sum and then you can further add measure to us this Error measure

 

Error = 
SUMX ( 
    VALUES ( 'Aggregated-Data'[Category] ), 
    ABS ( 
        CALCULATE ( SUM ( 'Aggregated-Data'[ORDERS] ) )-
        CALCULATE ( SUM ( 'Aggregated-Data'[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.



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.

parry2k
Super User
Super User

@Chava1881 is this what you are looking for?

 

parry2k_0-1638997802553.png

 

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.

 



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.

Unfortunately not, I need to Total number or WW number to be 18%. The issue I am having is that the right way to calculate it in excel is as shown in the screenshot below:
B2 is summing all FCST

C2 is summing all Orders

D2 is summing the error at the category level.

Chava1881_0-1638998214464.png

When using my measure it goes calculating the error by using the total sum of forecast and orders, making the MAPE 1%, and if I create a calculated column, as there are different regions and subregions, the error is higher than calculating it as shown in the excel.

Hope this makes sense. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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