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?
4 days ago in Power BI by Evanjalin
• 19,330 points
24 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 4 days ago by anonymous
• 19,330 points

Related Questions In Power BI

0 votes
0 answers
0 votes
2 answers

How do I create a Power BI visual that dynamically adjusts based on user-selected filters and slicers?

The application of slicers and filters in ...READ MORE

answered Jan 23 in Power BI by anonymous
• 16,840 points
136 views
0 votes
1 answer

How can I reduce the dataset size of a Power BI model that keeps hitting memory limits on Power BI Service?

In order to shrink the Power BI ...READ MORE

answered 3 days ago in Power BI by anonymous
• 19,330 points
28 views
0 votes
1 answer

How do I create a Power Query function that dynamically adjusts based on input parameters?

If you want to build a Power ...READ MORE

answered 1 day ago in Power BI by anonymous
• 19,330 points
21 views
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,130 points
1,526 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,130 points
2,870 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,654 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,802 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 1 day ago in Power BI by anonymous
• 19,330 points
15 views
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