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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
crisher
Helper I
Helper I

Averagex with a calculate filter

I am trying to calculate the average of the Billing Total MTD, but filter out weekends or Holidays. In the below, 0 indicates that the date is neither a weekend nor a holiday. I feel like I am missing something completely basic.
 
 
MTD Daily Average = CALCULATE(
AVERAGEX (
DATESMTD ( 'Calendar'[Billing Date] ),
[Billing Total] ),
'Calendar'[WeekendOrHoliday]=0
)
5 REPLIES 5
v-kkf-msft
Community Support
Community Support

Hi @crisher ,

 

If you only calculate the average for rows with data, then try the formula of @DataInsights . 

 

If you want to calculate the average for all weekdays in current month, try the following formula.

 

Measure = 
AVERAGEX ( 
    ADDCOLUMNS (
        CALCULATETABLE (
            'Calendar', 
            FILTER (
                'Calendar',
                'Calendar'[WeekendOrHoliday] = 0 
                    && FORMAT ( 'Calendar'[Billing Date], "YYYYMM" ) = FORMAT ( TODAY ( ), "YYYYMM" ) 
            )
        ),
        "BillingTotal", COALESCE ( [Billing Total], 0 )
    ),
    [BillingTotal]
)

 Screenshot 2022-01-24 143034.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

DataInsights
Super User
Super User

@crisher,

 

Try this measure:

 

MTD Daily Average =
CALCULATE (
    AVERAGEX ( 'Calendar', [Billing Total] ),
    DATESMTD ( 'Calendar'[Billing Date] ),
    'Calendar'[WeekendOrHoliday] = 0
)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hey @DataInsights, I think this is close. But, I do need the billings that are occurring over the weekend as part of Mondays' average calculation. Does that make sense?

Actually, I don't think this is right. At the moment, it is simply doing the average of that day. The intent is to do a running average for the month and remove holidays and weekends. Right now, it is just doing the average of that single day. See below...

 

 

crisher_0-1643112026895.png

 

@crisher,

 

As I understand it, you want to include all billings (numerator), but exclude weekends and holidays from the count of days (denominator). Revised measure:

 

MTD Daily Average = 
// include weekends and holidays
VAR vBillings =
    CALCULATE ( [Billing Total], DATESMTD ( 'Calendar'[Billing Date] ) )
// exclude weekends and holidays
VAR vDays =
    CALCULATE (
        COUNTROWS ( 'Calendar' ),
        DATESMTD ( 'Calendar'[Billing Date] ),
        'Calendar'[WeekendOrHoliday] = 0
    )
VAR vResult =
    DIVIDE ( vBillings, vDays )
RETURN
    vResult

 

DataInsights_0-1643120714261.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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