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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.