How can I create a measure that calculates the weighted average of a column dynamically based on slicer selections

0 votes
How can I create a measure that calculates the weighted average of a column dynamically based on slicer selections?

I need a Power BI measure that calculates the weighted average of a specific column, where the weights and values change dynamically based on slicer selections. What is the best way to implement this using DAX functions like SUMX, DIVIDE, or CALCULATE to ensure accurate calculations?
Mar 10 in Power BI by Evanjalin
• 25,690 points
75 views

1 answer to this question.

0 votes

Using SUMX and DIVIDE in DAX, a dynamic weighted average measure can be constructed in Power BI. The central theme is to compute the total weighted sum divided by the total weight while ensuring that the slicers' filters are applied.

Weighted average DAX formula.

Weighted Average = 
DIVIDE(
    SUMX( 'Table', 'Table'[Value] * 'Table'[Weight] ), 
    SUM( 'Table'[Weight] ), 
    0
)

Description:

SUMX('Table,' [Value] * [Weight]) → Multiplies each Value by the corresponding Weight and sums the products.

SUM('Table'[Weight]) → total weights in a dynamic manner as per depending on slicers.

DIVIDE(...) → Safe division is needed to avoid errors in cases where the denominator can probably be zero.

Essential Points:

This formula is responsive to the slicers and filters defined in Power BI.

If there are NULLs or zeros for weights, you can filter them out in the SUMX using FILTER().

For more complex scenarios, use CALCULATE() to scope the filter context.

answered Mar 10 by anonymous
• 25,690 points

Related Questions In Power BI

0 votes
1 answer

How can I create a customized tooltip that includes measures that change dynamically based on the hovered data point?

To make a customized tooltip that dynamically ...READ MORE

answered Mar 19 in Power BI by anonymous
• 25,690 points
62 views
0 votes
1 answer
0 votes
1 answer

How can I create a rolling calendar table that updates automatically based on the latest data in my fact table?

You can use either Power Query or ...READ MORE

answered Mar 13 in Power BI by anonymous
• 25,690 points
82 views
0 votes
1 answer
0 votes
1 answer

Displaying Table Schema using Power BI with Azure IoT Hub

Answering your first question, Event Hubs are ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by nirvana
• 3,090 points
1,595 views
+1 vote
1 answer

Unable to install connector for Power Bi and PostgreSQL

I think the problem is not at ...READ MORE

answered Aug 22, 2018 in Power BI by nirvana
• 3,090 points
2,934 views
+2 votes
2 answers

Migrate power bi collection to power bi embedded

I agree with Kalgi, this method is ...READ MORE

answered Oct 11, 2018 in Power BI by Hannah
• 18,520 points
1,719 views
+1 vote
1 answer

Connect power bi desktop to dataset and create custom reports

Open power bi report nd sign in ...READ MORE

answered Oct 10, 2023 in Power BI by Monika kale

edited Mar 5 1,881 views
0 votes
1 answer

How can I create a multi-row card that dynamically adjusts based on the number of selected values?

To create a multi-row card in Power ...READ MORE

answered Mar 18 in Power BI by anonymous
• 25,690 points
71 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP