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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Dave-ExpSC
Helper II
Helper II

AVEARAGEX BUT FILTER OUT A SINGLE VALUE

Still learning...

I have data from multiple companies and I want to do an average across the companies but I want to exclude 1 company from this average. I used a Quick Measure to calculate the average values that I am looking for but how can I modify it to exclude company "xyz"?

 

Avg Intensity SC1+2 by Revenue =
AVERAGEX(
    KEEPFILTERS(VALUES('2_Company_tbl'[Company])),
    CALCULATE(SUM('3a_GHG_Intensity SC1+2 Revenue'[Value]))
)

 

Your help is greatly appreciated

3 REPLIES 3
VahidDM
Super User
Super User

Hi @Dave-ExpSC 

 

Try this:

Avg Intensity SC1+2 by Revenue =
AVERAGEX (
    CALCULATETABLE (
        KEEPFILTERS ( VALUES ( '2_Company_tbl'[Company] ) ),
        FILTER ( '2_Company_tbl', '2_Company_tbl'[Company] <> "xyz" )
    ),
    CALCULATE ( SUM ( '3a_GHG_Intensity SC1+2 Revenue'[Value] ) )
)

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Thank you @VahidDM 

I'm getting an error message. I didn't metntion that I have a special character in front of the company name to help it sort to the top of company names "_xyz" - does that require something different?

 

KEEPFILTERS function can only be used as a top level filter argument of CALCULATE and CALCULATETABLE or with a table argument of a function performing a table scan.

Avg Intensity SC1-2 wo xyz =
AVERAGEX (
CALCULATETABLE (
KEEPFILTERS ( VALUES ( '2_Company_tbl'[Company] ) ),
FILTER ( '2_Company_tbl', '2_Company_tbl'[Company] <> "_xyz" )
),
CALCULATE ( SUM ( '3a_GHG_Intensity SC1+2 Revenue'[Value] ) )
)



Do you see the error?

Hi @Dave-ExpSC,

Can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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