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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
IgorAM
Helper I
Helper I

Wrong average

Hi community,

 

I'm having a problem to calculate a average.
There's two tables, a fact and a dimension (with goals), I made a relationship between them to get the goals.

Fact table is like that:

 

UnitRegionRealGoal (this is a calculated column)
BELS1.21.0
CGR

S

0.90.8
GYNS0.731.0
RBRW0.890.8
ESTE1.450.8
MCPS0.670.8
STMS0.490.8
LEMS1.53

0.8

LARW0.890.8
SLTW0.890.8
BURW0.891.0
RIOE1.450.8
SMPW0.891.0
SHEE1.450.8

 

Then, I used this Dax formula:

 

AVERAGE(fact_table[Goals])

 

And I got this when I use some filter for Region, in this case region "S":

 

af5f7a08-870f-451a-83b2-1005a78d78d8.jpg

 

The correct average should be: (2*1 + 4*0.8)/6 = 0.8667

 

What is happening?

 

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@IgorAM the total of the matrix is not the average of the rows in it. It's the average of the underlying data without filters. You have different number of rows per unit. The total is the weighted average.
If what you want is the average of averages than write this:

 

Measure = 
AVERAGEX(
    VALUES(fact_table[Unit]),
    CALCULATE(AVERAGE(fact_table[Goals]))
)

 

In case you put on the rows of the matrix the unit column from the dimension then swith in my function the VALUES(fact_table[Unit]) to VALUES(dim_table[Unit])


2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

6 REPLIES 6
Andras1
Frequent Visitor

Many thanks, SpartaBI! You solved a problem I have been struggling with for days.

IgorAM
Helper I
Helper I

I'm, now its working, thank you!!!

SpartaBI
Community Champion
Community Champion

@IgorAM my pleasure

SpartaBI
Community Champion
Community Champion

@IgorAM the total of the matrix is not the average of the rows in it. It's the average of the underlying data without filters. You have different number of rows per unit. The total is the weighted average.
If what you want is the average of averages than write this:

 

Measure = 
AVERAGEX(
    VALUES(fact_table[Unit]),
    CALCULATE(AVERAGE(fact_table[Goals]))
)

 

In case you put on the rows of the matrix the unit column from the dimension then swith in my function the VALUES(fact_table[Unit]) to VALUES(dim_table[Unit])


2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

3a12382f-2099-428a-9ba6-0e0894aafcf4.jpg

still doesnt work, I used the unit column from fact table

SpartaBI
Community Champion
Community Champion

@IgorAM you didn't put the calculate around the average. Look at the measure I wrote. Don't forget to accept the solution 🙂

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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