Forum Discussion
Calculated days
I have 2 dates and want to calculate working times between those and I want to calculate working days in a month using it. I have relationship between my date table and main table. Please guide me on the approach.
Please try the formula below:
Working Days in Month = CALCULATE ( COUNTROWS ( 'Date' ), WEEKDAY ( 'Date'[Date], 2 ) <= 5 )Hi! PowerZBI
You can use something like this, if I understood your problem. Check putting this in matrix visualDays Count =
VAR WO_Start =
CALCULATE(
MIN('Table'[Date1]),
ALL('Calendar')
)VAR WO_End =
CALCULATE(
MAX('Labor Data'[Date2]),
ALL('Calendar')
)VAR StartDate = INT(WO_Start)
VAR EndDate = INT(WO_End)VAR _days =
COUNTROWS(
FILTER(
'Calendar',
'Calendar'[CALENDAR_DATE] >= StartDate &&
'Calendar'[CALENDAR_DATE] <= EndDate &&
)
)RETURN
_days
4 Replies
- cengizhanarslan
Super User
Please try the formula below:
Working Days in Month = CALCULATE ( COUNTROWS ( 'Date' ), WEEKDAY ( 'Date'[Date], 2 ) <= 5 ) - FBergamaschi
Super User
Hi PowerZBI
what do you mean
want to calculate working times ?
Did you mean working days?
Furthermore, how do you define a working day? Whatever day is not Saturday or Sunday? Do you need to consider holydays / closing days also ?
If this helped, please consider giving kudos and mark as a solution
@me in replies or I'll lose your thread
Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page
Consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI
- AnkitKukreja
Super User
Hi! PowerZBI
You can use something like this, if I understood your problem. Check putting this in matrix visualDays Count =
VAR WO_Start =
CALCULATE(
MIN('Table'[Date1]),
ALL('Calendar')
)VAR WO_End =
CALCULATE(
MAX('Labor Data'[Date2]),
ALL('Calendar')
)VAR StartDate = INT(WO_Start)
VAR EndDate = INT(WO_End)VAR _days =
COUNTROWS(
FILTER(
'Calendar',
'Calendar'[CALENDAR_DATE] >= StartDate &&
'Calendar'[CALENDAR_DATE] <= EndDate &&
)
)RETURN
_days - Kedar_Pande
Super User
Working Days Between =
NETWORKDAYS(
MainTable[StartDate],
MainTable[EndDate]
)If this answer helped, please click 👍 or Accept as Solution.
-Kedar
LinkedIn: https://www.linkedin.com/in/kedar-pande