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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.