cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills 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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors