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
ClementSendra
New Member

averageif

Hello,

 

I try to integrate a column in a table which would calculate an average depending on the value in a column.

I know that it is possible to use a formula like : 

 

CALCULATE ( AVERAGE ( 'table', 'table[column2] ), FILTER ( 'table', 'table'[column1]="X" )

 

That's great but i don't want to precise a specific value like ( "X"), but compare the value of each row.

In an Excel table i would do : =AVERAGEIF([column 1],"="&[@[column 1]],[column 2])

 

 

Thank you inadvance.

Clement

 

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @ClementSendra

Can you show with an example what you need?  A small table with sample data and the required result.

I don't understand what you mean by

... i don't want to precise a specific value like ( "X"), but compare the value of each row.

 

Maybe this:

NewColumn =
CALCULATE (
    AVERAGE ( 'table'[column2] ),
    FILTER ( 'table', 'table'[column1] = EARLIER ( 'table'[column1] ) )
)

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

 

Drag Column1 to the Table visual and write this measure

 

=AVERAGE('table'[column2])


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hello,

 

How do you get this to work in a table with 10+ columns of data? Given all the columns it doesn't average, just shows the result matching the column I need the average for.

 

Regards,

James

AlB
Community Champion
Community Champion

Hi @ClementSendra

Can you show with an example what you need?  A small table with sample data and the required result.

I don't understand what you mean by

... i don't want to precise a specific value like ( "X"), but compare the value of each row.

 

Maybe this:

NewColumn =
CALCULATE (
    AVERAGE ( 'table'[column2] ),
    FILTER ( 'table', 'table'[column1] = EARLIER ( 'table'[column1] ) )
)

Thank you for your message,

 

For each row, i want to compare the value in [column1] and calculate an average of the [Column2] of all the rows having the same value in [column1]

 

In excel :

 

Column 1         Column 2         Average

      c                      6                      6                             Average = AVERAGEIF([Column 1],"="&[@[column 1]),[column 2])    

      a                      1                      1

      c                      2                      6

      b                      2                      3

      b                      4                      3

      c                     10                     6

 

Thank you for your help !
Clement

@ClementSendra

Ok, so both answers above should work. Mine if you want it in a calculated column and @Ashish_Mathur's if you want it with a measure.

Thank you very much it is exactly what i was looking for !

 

Clement

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.

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