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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
EEPB
Regular Visitor

Taking the Average of Values only if they meet a Criteria

I have 4 columns containing data, I would like to know the average of these columns per row, but only if they contain data that meets a set criteria, otherwise I need the data excluded from the average calculation. For example, I want to take the average of these four columns (C 1-4) but to exclude any value less than 10 from the average. 

 

C1C2C3C4AVG Needed Actual AVG
20304053023.75
2202022011

 

Ex.) I attempted using a version of the following code for a calculated column with no success.

 

AVG_C =
AVERAGE(
    (IF(C1>(10),C1,),
    IF(C2>(10),C2,),
    IF(C3>(10),C3,),
    IF(C4>10(10),C4,))
)
1 REPLY 1
FreemanZ
Super User
Super User

hi @EEPB 

1) tranpose the data table in Power Query Editor to:

FreemanZ_0-1677139658858.png

 

2) then write two measures like:

Columm2Avg = 
AVERAGEX(
    FILTER(
        TableName,
        TableName[Column2]>=10
    ),
    TableName[Column2]
)

Columm3Avg = 
AVERAGEX(
    FILTER(
        TableName,
        TableName[Column3]>=10
    ),
    TableName[Column3]
)

 

it worked like:

FreemanZ_1-1677139713763.png

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors