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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Calculate business days till today on per month basis

Hello there,

 

I am trying to calculate business days (and eventually business hours) per month, so I can use it in calculating machine efficiency. (Numer of hours machine has worked so far this month devided by total hours available).

 

I have Date Dimension table.

MoeGhanavizi_0-1642081093731.png

 

 And, this is the table from which I am calculating the total hours that a machine has worked.

MoeGhanavizi_1-1642081157381.png

 

Could you help me with this?

 

Thanks,

 

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Did you mean how many workdays are there in that month until the [FullDateAlternateKey]?

If yes,

 

workdays*hours =
VAR _hour_per_day = 8 //How many hours of work per day. 
VAR _Calendar =
    CALENDAR( DATE( [year], [month], 1 ), [FullDateAlternateKey] )
VAR _add =
    ADDCOLUMNS(
        _Calender,
        "workday", IF( WEEKDAY( [FullDateAlternateKey], 2 ) < 6, 1, 0 )
    )
RETURN
    COUNTROWS( FILTER( _add, [workday] = 1 ) ) * _hour_per_day

 

Best Regards

Community Support Team _ chenwu zhu

 

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-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Did you mean how many workdays are there in that month until the [FullDateAlternateKey]?

If yes,

 

workdays*hours =
VAR _hour_per_day = 8 //How many hours of work per day. 
VAR _Calendar =
    CALENDAR( DATE( [year], [month], 1 ), [FullDateAlternateKey] )
VAR _add =
    ADDCOLUMNS(
        _Calender,
        "workday", IF( WEEKDAY( [FullDateAlternateKey], 2 ) < 6, 1, 0 )
    )
RETURN
    COUNTROWS( FILTER( _add, [workday] = 1 ) ) * _hour_per_day

 

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Anonymous
Not applicable

@amitchandak  Thanks for the reply. The solutoin is returning 0 and 1 only. 

 

MoeGhanavizi_0-1642082967544.png

 

amitchandak
Super User
Super User

@Anonymous , You can create a column like this in date table and use that as filter for business days

 

WorkDay= if( weekday([Date],2)<6 ,1,0)

 

refer

How to calculate Business Days/ Workdays, with or without date table: https://youtu.be/Qv4wT8_P-AA

 

https://exceleratorbi.com.au/calculating-business-hours-using-dax/

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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