How to calculate business days in the current month in Power Apps?
To calculate the number of business days (weekdays) in the current month, excluding weekends, you can use the following PowerApps formula:
CountRows(
Filter(
With({SelectedMonth: Month( Today()), SelectedYear: Year(Today())},
With({startDate: Date(SelectedYear, SelectedMonth, 1),
endDate: DateAdd(DateAdd(Date(SelectedYear, SelectedMonth, 1), 1, TimeUnit.Months), -1, TimeUnit.Days)
},
ForAll(
Sequence(DateDiff(startDate, endDate, TimeUnit.Days)+1),
Date(SelectedYear, SelectedMonth, Value)
)
)
),
Weekday(Value) <> 6 && Weekday(Value) <> 7
) )
Note : replace the number of week end days in your calendar instead of 6 and 7 as I suppose the week start with Sunday.
This formula calculates the number of business days in the current month by filtering a collection of dates representing each day in the month, excluding Saturdays and Sundays. It dynamically adjusts to the current month and year using the Today()
function