Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
592 views
in Power Apps by 30 37 42
edited by
I am building a Canvas app application that need to count the buisness days of the month in Power Apps, What PowerApps formula can be used to calculate the number of business days (weekdays) in the current month, excluding weekends, considering the dynamic changes in the number of days each month?

1 Answer

2 like 0 dislike
by 48 54 93
selected by
 
Best answer

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

If you don’t ask, the answer is always NO!
...