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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
i_kafali
Helper II
Helper II

Weighted Average for only one column

 

Dear all,

 

I have below fields Department and Product and numbers for volume and sales price

 

What i want to add is another measure which calculates only departments average unit sales price. Therefore i can compare product's average price versus departments average.

 

What kind of Dax formula should i make?

 

Thanks,

 

 

DepartmentProductVolume (kg)Unit Sales PriceDepartment Unit Sales Price
AX1101,11,19
AX2201,21,19
AX1401,21,19
BX2501,31,31
BX4201,41,31
BX3151,21,31
CX1251,51,37
CX5301,21,37
CX4501,41,37
1 ACCEPTED SOLUTION

Hi @i_kafali

 

You may try to create below measures:

Volume*Unit Sales Price =
CALCULATE ( SUM ( Table1[Volume (kg)] ) * SUM ( Table1[Unit Sales Price] ) )
Measure =
SUMX ( ALLEXCEPT ( Table1, Table1[Department] ), [Volume*Unit Sales Price] )
    / CALCULATE (
        SUM ( Table1[Volume (kg)] ),
        ALLEXCEPT ( Table1, Table1[Department] )
    )

1.png

 

Regards,

Cherie

Community Support Team _ Cherie Chen
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

4 REPLIES 4
AlB
Super User
Super User

Hi @i_kafali

What is the exact calculation you want to perform to compute the average? Average per product and department taking the volume into account? Can you provide a  clear illustrative example?

Below is the excel formula i want to perform in power bi

 

I have many fields in my dataset but in my calculation i want to calculate weighted average unit sales price of department so in the visual report i can show which products are below department's average which are above.

 

Using ALL or ALLEXCEPT dax formulas does not work since i have many other fields which induces a wrong result.

 

Capture.PNG

Hi @i_kafali

 

You may try to create below measures:

Volume*Unit Sales Price =
CALCULATE ( SUM ( Table1[Volume (kg)] ) * SUM ( Table1[Unit Sales Price] ) )
Measure =
SUMX ( ALLEXCEPT ( Table1, Table1[Department] ), [Volume*Unit Sales Price] )
    / CALCULATE (
        SUM ( Table1[Volume (kg)] ),
        ALLEXCEPT ( Table1, Table1[Department] )
    )

1.png

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@i_kafali

Try this:

1. Place a matrix visual in your report

2. Place Table1[Department] in the rows of the matrix

3. Place this measure in values of the matrix:

 

 

Measure =
DIVIDE (
    SUMX ( Table1, Table1[Volume (kg)] * Table1[Department Unit Sales Price] ),
    SUMX ( Table1, Table1[Volume (kg)] )
)

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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