Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

count of no of working days

(0) ShareShare
ReportReport
Posted on by

i have used below code to count no of working days based on datepicker1 but when i select feb month showing wrong data .how to fix this?
With(
{
varDateRange: ForAll(
Sequence(31,1),
Text(Month(DataCardValue4.SelectedDate) & "/" & Value & "/" & Year(DataCardValue4.SelectedDate),"DD/MM/YYYY")
)
},
// show only dates Monday to Friday and exclude holidays
CountIf(
varDateRange,
And(
Weekday(Value,StartOfWeek.Sunday) in [2, 3, 4, 5, 6],
Not(Value in Col_Holidaylist.Date1)
)
)
)

Categories:
  • venky232 Profile Picture
    on at
    Re: count of no of working days

    error sequence as invalid arguments
    Days is unknown or unsupported function

  • Rajkumar_M Profile Picture
    3,631 Super User 2025 Season 1 on at
    Re: count of no of working days

    Try this

    With(
    {
    varStartDate: Date(Year(DataCardValue4.SelectedDate), Month(DataCardValue4.SelectedDate), 1),
    varEndDate: Date(Year(DataCardValue4.SelectedDate), Month(DataCardValue4.SelectedDate) + 1, 1),
    varDateRange: Filter(
    AddColumns(
    Sequence(Days(varEndDate - varStartDate), 0),
    "Date",
    DateAdd(varStartDate, Value, Days(1))
    ),
    Not(DateAdd(varStartDate, Value, Days(1)) in Col_Holidaylist.Date1) &&
    Weekday(DateAdd(varStartDate, Value, Days(1)), StartOfWeek.Sunday) in [2, 3, 4, 5, 6]
    )
    },
    CountRows(varDateRange)
    )

  • venky232 Profile Picture
    on at
    Re: count of no of working days

    not working code sequence as some invalid arguments

  • Rajkumar_M Profile Picture
    3,631 Super User 2025 Season 1 on at
    Re: count of no of working days

    Hi

    The issue with the formula you provided for counting the number of working days based on the selected date is that it assumes that February has 31 days. To fix this issue, you can modify the formula to use the Days function to get the number of days in the selected month. 

     

    With( 
    { varDateRange:

    ForAll( Sequence(Days(DataCardValue4.SelectedDate), 1),
    Text(Value & "/" & Month(DataCardValue4.SelectedDate) & "/" &
    Year(DataCardValue4.SelectedDate), "DD/MM/YYYY") ) },

    // show only dates Monday to Friday and exclude holidays

    CountIf( varDateRange, And( Weekday(Value, StartOfWeek.Sunday) in [2, 3, 4, 5, 6],
    Not(Value in Col_Holidaylist.Date1) ) ) )
     

     

    Thanks!

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,708 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,030 Most Valuable Professional

Leaderboard