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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Gathoni
New Member

DAX

 

Hi all, just started using PowerBI in reporting and I need your help 🙂

I have sales and forecast by product, customer and week. 

 

I need to calculate forecast absolute deviation over any filter context such that deviation over customer can cancel out but over product deviation accumulates. 

 

Here is sample calculation

 

ProductCustomerWeekforecastsalesdeviation
AX120182
AX21820-2
AY133275
AY216106
BX115114
BX22428-4
BY1402614
BY224222
Total    27

 

 

I need a measure 'absolute deviation' such as that the total/sum 'absolute deviation' is 31 instead of 27

 

and  'absolute deviation' over week is such that 

 

Weekabsolute deviation 
125
26
Total31

 

and  'absolute deviation' over product and week is such that

 

productWeekabsolute deviation 
A17
A24
B118
B2-2
Total 31

 

Any leads on how I can write this measure is welcome.... 

Thanks 
Gathoni

1 ACCEPTED SOLUTION
v-yinliw-msft
Community Support
Community Support

Hi @Gathoni ,

 

According to your description, I assume that you need the ABS, you can try this method:

Create a new table to calculate.

New table:

Table 2 =
SUMMARIZE (
    'Table',
    'Table'[Week],
    'Table'[Product],
    "absolute deviation", SUM ( 'Table'[deviation] )
)

In the table, add a new column:

ABS = ABS('Table 2'[absolute deviation])

Then in the Table, create three measures:

ABS = SUM('Table 2'[ABS])
NOTABS = SUM('Table 2'[absolute deviation])
Result =
IF ( HASONEVALUE ( 'Table 2'[absolute deviation] ), [NOTABS], [ABS] )

The result is :

vyinliwmsft_0-1667373056607.png

 

 

For more information you can find in the .pbix  file.

 

 

Hope this helps you.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yinliw-msft
Community Support
Community Support

Hi @Gathoni ,

 

According to your description, I assume that you need the ABS, you can try this method:

Create a new table to calculate.

New table:

Table 2 =
SUMMARIZE (
    'Table',
    'Table'[Week],
    'Table'[Product],
    "absolute deviation", SUM ( 'Table'[deviation] )
)

In the table, add a new column:

ABS = ABS('Table 2'[absolute deviation])

Then in the Table, create three measures:

ABS = SUM('Table 2'[ABS])
NOTABS = SUM('Table 2'[absolute deviation])
Result =
IF ( HASONEVALUE ( 'Table 2'[absolute deviation] ), [NOTABS], [ABS] )

The result is :

vyinliwmsft_0-1667373056607.png

 

 

For more information you can find in the .pbix  file.

 

 

Hope this helps you.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

grantsamborn
Solution Sage
Solution Sage

1. The 3rd line of your sample data shows [deviation] as 5 when it should be 6.
2. I can’t figure out what you mean by “absolute deviation” and its total being equal to 31.

 

https://1drv.ms/u/s!AnF6rI36HAVkhPF41NlaDnqg9IdTWA?e=N4ibe0

 

Helpful resources

Announcements
Europe Fabric Conference

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.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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