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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
klehar
Helper V
Helper V

Average excepts only column reference

klehar_0-1743071254890.png

Can anyone help with the above error and a workaround?

Justlike average i also need 50th percentile, 75th percentile for creating box plots

so percentile.inc is also not working with this

1 ACCEPTED SOLUTION
FarhanJeelani
Super User
Super User

Hi @klehar ,

The error in your DAX formula occurs because the AVERAGE function only accepts a column reference as an argument, but you are passing an expression (1 - DIVIDE(netprice, listprice)).

 

Solution:
Instead of using AVERAGE, use the AVERAGEX function, which allows row-wise calculations on a table.

Corrected Code:
DAX

RETURN
IF(
listprice <> 0,
AVERAGEX(
TableName,
1 - DIVIDE(TableName[netprice], TableName[listprice])
),
BLANK()
)


AVERAGEX iterates over the TableName and computes the expression for each row before averaging the results.

TableName should be replaced with your actual table name containing netprice and listprice.

 

Please mark this post as solution if it helps you. Appreciate Kudos.

View solution in original post

3 REPLIES 3
FarhanJeelani
Super User
Super User

Hi @klehar ,

The error in your DAX formula occurs because the AVERAGE function only accepts a column reference as an argument, but you are passing an expression (1 - DIVIDE(netprice, listprice)).

 

Solution:
Instead of using AVERAGE, use the AVERAGEX function, which allows row-wise calculations on a table.

Corrected Code:
DAX

RETURN
IF(
listprice <> 0,
AVERAGEX(
TableName,
1 - DIVIDE(TableName[netprice], TableName[listprice])
),
BLANK()
)


AVERAGEX iterates over the TableName and computes the expression for each row before averaging the results.

TableName should be replaced with your actual table name containing netprice and listprice.

 

Please mark this post as solution if it helps you. Appreciate Kudos.

Thanks for the reply

What about percentile.inc?

Hi @klehar ,

Just like AVERAGE, the PERCENTILE.INC function in Power BI also requires a column reference and does not accept row-wise calculations directly.

 

Use PERCENTILEX.INC Instead
To calculate percentiles based on an expression, use PERCENTILEX.INC, which allows iteration over a table (similar to AVERAGEX).

Corrected Code for 50th & 75th Percentile
DAX

RETURN
IF(
SELECTEDVALUE(TableName[listprice]) <> 0,
PERCENTILEX.INC(
TableName,
1 - DIVIDE(TableName[netprice], TableName[listprice]),
0.50 -- Change to 0.75 for the 75th percentile
),
BLANK()
)

 

Please mark this post as solution if it helps you. Appreciate Kudos.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

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.