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
fedeleu
Frequent Visitor

Average

Hi!

I have a model with the next table (this is a small sample of a much larger base)

 

NameYearMonthReviewCountWeight
Name120211A1410
Name120211A1160
Name120213A2530
Name120219A325
Name220218B1110
Name2202110B2110

 

 

For each "Name", I must first group by "Review" and calculate the difference between 100 and the sum of its "Weight".

So, I create two measures

 

aux = SUMX([Table],Table[Count]*Table[Weight])
 
aux2 =
VAR CUENTA=100-[aux]
VAR CUENTA2=IF(CUENTA<0,0,CUENTA)
RETURN
IF([aux]<1,BLANK(),CUENTA2)
 
 

I get the following results, which were as expected

 

NameReviewaux2
Name1A10
Name1A20
Name1A390
Name2B190
Name2B290

 

OK, now is when I have a problem.

 

For each "Name", I must calculate the average of "aux2"

 

I created the following measure, but I'm not getting the expected results.

 

avg= AVERAGEX(NC_Peso_KPI,[aux2])
 
Nameavgavg_expected
Name147,530
Name29090

 

Can someone help me find the error?

 

Regards,

Federico.

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

The reason it's giving this is that you are averaging at the table row granularity. That is, averaging these values:

AlexisOlson_0-1636734805393.png

 

To fix this, you need to average over the appropriate granularity:

avg = AVERAGEX ( SUMMARIZE ( Peso, Peso[Name], Peso[Review] ), [aux2] )

AlexisOlson_1-1636734936725.png

View solution in original post

3 REPLIES 3
fedeleu
Frequent Visitor

Thanks for your help @AlexisOlson,
Can I bother you with another question?
I have 2 date slicers (one for month and one for year), both single-select.
Since the calculation of "avg" I must do it 12 months back, I adapted the measure as follows (there is a column "Date" that I did not name before)

Table [Date] is linked with Calendar [Date]

 

avg = CALCULATE(AVERAGEX (SUMMARIZE ( Table, Table[Name], Table[Review],Table[Date] ), [aux2] ),DATESBETWEEN(Calendar[Date],NEXTDAY(SAMEPERIODLASTYEAR(LASTDATE(Calendar[Date]))),LASTDATE(Calendar[Date])))

 

But doesnt work.

I get, at least in a small sample that I made, the same values ​​as without having made the change to your formula.

 

Any suggestion?

Thanks you

I can't quite tell what's going on from this description. You may want to create a new post with more detail and, ideally, link to a sample file others can follow along with.

AlexisOlson
Super User
Super User

The reason it's giving this is that you are averaging at the table row granularity. That is, averaging these values:

AlexisOlson_0-1636734805393.png

 

To fix this, you need to average over the appropriate granularity:

avg = AVERAGEX ( SUMMARIZE ( Peso, Peso[Name], Peso[Review] ), [aux2] )

AlexisOlson_1-1636734936725.png

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.