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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Nanakwame
Helper II
Helper II

Exclude values from Average calculation

Hi,

 

I have a matrix table created with with average sales for each department. We recently added a new department that did not have any sales for 2 months before generating sales. Due to this, the average for that particular branch is wrongly reported. I will like to exclude the months without sales from the average just for that department only in order to get the right average begining from the month sales started generating. 

 

Any idea on how i can calculate average for just one department without the 0 sales months being included?

 

Thank you 

1 ACCEPTED SOLUTION
rbriga
Impactful Individual
Impactful Individual

You're right. This worked for me, then:

SalesFiltered =
VAR _Exclude =
    CALCULATE (
        SUM(dailyKPI[Sales]),
        KEEPFILTERS ( dailyKPI[Warehouse] = "60"),    
        KEEPFILTERS ( dailyKPI[Month - Year] IN {"September 2020","October 2020""November 2020""December 2020""August 2021","September 2021","October 2021"} )
    )
RETURN
    SUM(dailyKPI[Sales]) - _Exclude

 

--NOTE: if possible, apply the filters to the dimension table (not the fact table)

-------------------------
Data analyst by day, hockey goalie by night.
Did I help? Then please hit that "kudos" or "accept as a solution" button!

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

The result of the average function will not get affected by blank cells but will get affected by 0's.  If you can share your data and show the expected result, i can offer assistance.


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

Is this a specific, non-repeating scenario?

If so, you may add to CALCULATE the modifier KEEPFILTERS:

=CALCULATE(

{Formula},

KEEPFILTERS(NOT(AND('Sales'[Department]="Department X", 'Calendar'[Year-Month] IN {2021-02,2021-03})

)

-------------------------
Data analyst by day, hockey goalie by night.
Did I help? Then please hit that "kudos" or "accept as a solution" button!

@rbriga 

 

Hi

 

I tried this measure and it didnt work. I get an error. 

SalesFiltered = CALCULATE(
SUM(dailyKPI[Sales]),
KEEPFILTERS(NOT(AND(dailyKPI[Warehouse] = "60", dailyKPI[Month - Year] IN {"September 2020","October 2020", "November 2020", "December 2020", "August 2021","September 2021","October 2021"}))))
rbriga
Impactful Individual
Impactful Individual

You're right. This worked for me, then:

SalesFiltered =
VAR _Exclude =
    CALCULATE (
        SUM(dailyKPI[Sales]),
        KEEPFILTERS ( dailyKPI[Warehouse] = "60"),    
        KEEPFILTERS ( dailyKPI[Month - Year] IN {"September 2020","October 2020""November 2020""December 2020""August 2021","September 2021","October 2021"} )
    )
RETURN
    SUM(dailyKPI[Sales]) - _Exclude

 

--NOTE: if possible, apply the filters to the dimension table (not the fact table)

-------------------------
Data analyst by day, hockey goalie by night.
Did I help? Then please hit that "kudos" or "accept as a solution" button!

Hi, 

 

You can try unchecking the "Show items with no data" option.

For Eg., in the below image i dont have any sales for the Descripton "ccc". since the "Show items with no data" has been checked it shows that record. 

 

 

Aburar_123_0-1637494020941.png

 

see it after uncheck this option,

 

Aburar_123_1-1637494095902.png

 

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors