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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
RichFrederick
Frequent Visitor

Calculating averages using a filter

 

Hi all, 

Hit a roadblock, trying to find the overall average for "rate" that occurs in multiple columns. Some of the data has "0" and I want to exclude them. How do I apply a filter to exclude rows that have "0" in their values? 

 


2018 AVG RATE = AVERAGE('ALP2018 Daily Rate'[Rate])+AVERAGE('HUF2018 Rate'[Rate])+AVERAGE('KPH2018 Rate'[Rate])+AVERAGE('GROUP2018 Rate'[Rate])+AVERAGE('INDY2018 Rate'[Rate])+AVERAGE('LKE2018 Rate'[Rate])+AVERAGE('LOCAL2018 Rate'[Rate])

 

Thanks

1 ACCEPTED SOLUTION

Hi @RichFrederick,

 

Try this formula below.

 

Overall Occupancy =
CALCULATE (
    AVERAGE ( 'CHI2018 Occ'[Occupancy] ),
    FILTER ( 'CHI2018 Occ', 'CHI2018 Occ'[Occupancy] <> 0 )
)
    + CALCULATE (
        AVERAGE ( 'DET2018 Occ'[Occupancy] ),
        FILTER ( 'DET2018 Occ', 'DET2018 Occ'[Occupancy] <> 0 )
    )
    + CALCULATE (
        AVERAGE ( 'GROUP2018 Occ'[Occupancy] ),
        FILTER ( 'GROUP2018 Occ', 'GROUP2018 Occ'[Occupancy] <> 0 )
    )
    + CALCULATE (
        AVERAGE ( 'IOWA2018 Occ'[Occupancy] ),
        FILTER ( 'IOWA2018 Occ', 'IOWA2018 Occ'[Occupancy] <> 0 )
    )
    + CALCULATE (
        AVERAGE ( 'MIN2018 Occ'[Occupancy] ),
        FILTER ( 'MIN2018 Occ', 'MIN2018 Occ'[Occupancy] <> 0 )
    )
    + CALCULATE (
        AVERAGE ( 'REMOTE2018 Occ'[Occupancy] ),
        FILTER ( 'REMOTE2018 Occ', 'REMOTE2018 Occ'[Occupancy] <> 0 )
    )

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @RichFrederick,

 

You could refer to the formula below.

 

 

average=CALCULATE(AVERAGE('ALP2018 Daily Rate'[Rate]),FILTER('ALP2018 Daily Rate','ALP2018 Daily Rate'[Rate]<>0))

If you still need help, please share some data sample which could reproduce your scenario and your expected output, so that we can help further investigate on it?

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you!! I got that to work for one, but how do I apply the <>0 filter to the DAX below?  I've tried writing the filter after each I get the following: A function 'FILTER' has been used in a True/False expression that is used as a table filter expression. This is not allowed.


Overall Occupancy = CALCULATE(AVERAGE('CHI2018 Occ'[Occupancy]),FILTER('CHI2018 Occ','CHI2018 Occ'[Occupancy]<>0)+AVERAGE('CIN2018 Occ'[Occupancy]),FILTER('CIN2018 Occ','CIN2018 Occ'[Occupancy]<>0)+AVERAGE('DET2018 Occ'[Occupancy]),FILTER('DET2018 Occ','DET2018 Occ'[Occupancy]<>0)+AVERAGE('GROUP2018 Occ'[Occupancy]),FILTER('GROUP2018 Occ','GROUP2018 Occ'[Occupancy]<>0)+AVERAGE('IOWA2018 Occ'[Occupancy]),FILTER('IOWA2018 Occ','IOWA2018 Occ'[Occupancy]<>0)+AVERAGE('MIN2018 Occ'[Occupancy]),FILTER('MIN2018 Occ','MIN2018 Occ'[Occupancy]<>0)+AVERAGE('REMOTE2018 Occ'[Occupancy]),FILTER('REMOTE2018 Occ','REMOTE2018 Occ'[Occupancy]<>0))

Hi @RichFrederick,

 

Try this formula below.

 

Overall Occupancy =
CALCULATE (
    AVERAGE ( 'CHI2018 Occ'[Occupancy] ),
    FILTER ( 'CHI2018 Occ', 'CHI2018 Occ'[Occupancy] <> 0 )
)
    + CALCULATE (
        AVERAGE ( 'DET2018 Occ'[Occupancy] ),
        FILTER ( 'DET2018 Occ', 'DET2018 Occ'[Occupancy] <> 0 )
    )
    + CALCULATE (
        AVERAGE ( 'GROUP2018 Occ'[Occupancy] ),
        FILTER ( 'GROUP2018 Occ', 'GROUP2018 Occ'[Occupancy] <> 0 )
    )
    + CALCULATE (
        AVERAGE ( 'IOWA2018 Occ'[Occupancy] ),
        FILTER ( 'IOWA2018 Occ', 'IOWA2018 Occ'[Occupancy] <> 0 )
    )
    + CALCULATE (
        AVERAGE ( 'MIN2018 Occ'[Occupancy] ),
        FILTER ( 'MIN2018 Occ', 'MIN2018 Occ'[Occupancy] <> 0 )
    )
    + CALCULATE (
        AVERAGE ( 'REMOTE2018 Occ'[Occupancy] ),
        FILTER ( 'REMOTE2018 Occ', 'REMOTE2018 Occ'[Occupancy] <> 0 )
    )

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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