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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors