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
AshDil
Helper V
Helper V

Want to show weighted average value DAX

Hi,

I have data as follows:

Category    HourRate    Value
C                4.44             94.09
D               8.13              100

I want to calculate following:

Weighted average factor for Category C : 4.44 / 12.57 (i.e,Sum of Hourrate for Cat C & D) = 0.353

Weighted average factor for Category D : 8.13 / 12.57 (i.e,Sum of Hourrate for Cat C & D) = 0.647

And I want to show the following in KPI

In Slicer Cat C is selected,

Measure value = 94.09 

In Slicer Cat C & D are selected,

Measure Value = 94.09 * 0.353 + 100 * 0.647 = 97.89

 

Please help me to do.

 

Thanks,

AshDil.

 

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

Hi @AshDil ,

You can create a measure as below to get it:

Measure = 
VAR _sumofrate =
    CALCULATE ( SUM ( 'Table'[HourRate] ), ALLSELECTED ( 'Table' ) )
VAR _tab =
    ADDCOLUMNS (
        'Table',
        "nvalue", 'Table'[Value] * DIVIDE ( 'Table'[HourRate], _sumofrate )
    )
RETURN
    SUMX ( _tab, [nvalue] )

yingyinr_0-1628844775671.png

Best Regards

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

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @AshDil ,

You can create a measure as below to get it:

Measure = 
VAR _sumofrate =
    CALCULATE ( SUM ( 'Table'[HourRate] ), ALLSELECTED ( 'Table' ) )
VAR _tab =
    ADDCOLUMNS (
        'Table',
        "nvalue", 'Table'[Value] * DIVIDE ( 'Table'[HourRate], _sumofrate )
    )
RETURN
    SUMX ( _tab, [nvalue] )

yingyinr_0-1628844775671.png

Best Regards

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

Hi @v-yiruan-msft ,

Thanks. It worked.

Regards,

AshDil

Vera_33
Resident Rockstar
Resident Rockstar

Hi @AshDil 

 

Here is one way, assume the slicer column from your fact table

test = 
VAR T1=ADDCOLUMNS('yourTable',"AVG",'yourTable'[HourRate]/SUM('Table'[HourRate])*'yourTable'[Value])
RETURN
SUMX(T1,[AVG])

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.