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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Sum of Average of Category

I have data that looks like this:

ElementValue

Product

Iron4

1

Iron8

1

Sulphur3

1

Iron0

1

Sulphur3

1

Manganese6

1

 

I need to get the average of every element except one Element, then the average of that last element. Do some calculations and return the result... I have page filters that needs to be taken into account (on Product amongst others).

 

This is what i tried, but the result don't match my manual calculations.

 

SUM = 
(CALCULATE(
    AVERAGE('Analysis'[Value]),
    FILTER('Analysis', 'Analysis'[Element] = "Iron")  
) * 1.382)
+ 
(CALCULATE(
    AVERAGE('Analysis'[Value]),
    FILTER('Analysis', 'Analysis'[Element] <> "Iron")
) + 1.2)

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I managed to find the solution.

 

SUMX(
    GROUPBY(
        'Analysis',[Element],
        "Element_grp", MAXX(CURRENTGROUP(),[Element]),
        "Value_avg", AVERAGEX(CURRENTGROUP(),[Value])
    ),
    IF([Element_grp] = "Iron", [Value_avg] * 1.382, [Value_avg])
)+1.2

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

I can add in that the first half of the measure works as expected. 

The second one seems to average all values from all categories, not for each category, and it results in a much lower number than expected.

amitchandak
Super User
Super User

@Anonymous at once place you are multiplying bt 1.3 and at the second place you are adding 1.2 . That you need at line level or total level. The information you have provided is not making the problem clear to me. Can you please explain with an example.

Appreciate your Kudos.


Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

What i was handed on a post-it note was the following:
(Iron * 1.382) + (Oxides) + 1.2

Where Iron is the average of all Iron values, and Oxides is the sum of the average value of all other elements.

The multiplying/adding is some adjustments that has to be done before presenting the result.

Anonymous
Not applicable

I managed to find the solution.

 

SUMX(
    GROUPBY(
        'Analysis',[Element],
        "Element_grp", MAXX(CURRENTGROUP(),[Element]),
        "Value_avg", AVERAGEX(CURRENTGROUP(),[Value])
    ),
    IF([Element_grp] = "Iron", [Value_avg] * 1.382, [Value_avg])
)+1.2

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.