web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Onchange Properties
Power Apps
Answered

Onchange Properties

(0) ShareShare
ReportReport
Posted on by 188

 Hi All,  Onchange properties on my dropdown if  you selected "N/A"  UpdateContext({varCalculationActive1: false}) and when you select "Paid"  UpdateContext({varCalculationActive1: true}), now i want automatic change my dropdown to N/A and my number of days should be zero and disabled all the Paid leave fields, if the Value of Remaining leave is zero. 

 

Update : I can now manage to automatic change my dropdown to "N/A"  once the remaining leave is zero using the code in my defaultselected item properties and disabled it. but my problem now is my number of days is not changing.

 

Onchange properties dropdown:

 

 

If(
 PaidDrop.Selected.Value = "Paid",
 UpdateContext({varCalculationActive1: true}) || PaidDrop.Selected.Value = "N/A",
 UpdateContext({varCalculationActive1: false})
 )

 

 

 

DefaultSelectedItem:

 

 

If(
 Leavetype.Selected.Value = "Paternity leave" && Value(TextInput1_12.Text) = 0 || Leavetype.Selected.Value = "Vacation Leave" && Value(TextInput1_9.Text) = 0 || Leavetype.Selected.Value = "Sick Leave" && Value(TextInput1_9.Text) = 0 || Leavetype.Selected.Value = "Emergency Leave" && Value(TextInput1_9.Text) = 0 || Leavetype.Selected.Value = "Maternity leave" && Value(TextInput1_21.Text) = 0 || Leavetype.Selected.Value = "Bereavement Leave" && Value(TextInput1_24.Text) = 0 || Leavetype.Selected.Value = "Leave for Victim of Violence (Women&Children)" && Value(TextInput1_27.Text) = 0 || Leavetype.Selected.Value = "Parental Leave for Solo Parent" && Value(TextInput1_18.Text) = 0 || Leavetype.Selected.Value = "Special Leave for Women" && Value(TextInput1_30.Text),
 Table({Value: "N/A"}),
 Table({Value: "Paid"})
)

 

 

number of days

If(varCalculationActive1,
 If(

 Leavetype.Selected.Value = "Maternity leave",
 If(
 StartDates.SelectedDate <= EndDates.SelectedDate,
 DateDiff(
 StartDates.SelectedDate,
 EndDates.SelectedDate,
 Days
 ) + 1 - If(
 Checkbox3.Value,
 0.5
 )
 ),
 (If(
 StartDates.SelectedDate = EndDates.SelectedDate,
 Sum(
 If(
 Weekday(StartDates.SelectedDate) = 1,
 0,
 1
 )
 ) - If(
 Checkbox3.Value,
 0.5
 ),
 If(
 StartDates.SelectedDate > EndDates.SelectedDate,
 -Sum(
 ForAll(
 Sequence(
 DateDiff(
 EndDates.SelectedDate,
 StartDates.SelectedDate,
 Days
 ),
 0,
 1
 ),
 If(
 Weekday(
 DateAdd(
 EndDates.SelectedDate,
 Value
 )
 ) = 1,
 {DayCount: 0},
 {DayCount: 1}
 )
 ),
 DayCount
 ) - If(
 Checkbox3.Value = false,
 0.5
 ) - 1/2,
 Sum(
 ForAll(
 Sequence(
 DateDiff(
 StartDates.SelectedDate,
 EndDates.SelectedDate,
 Days
 ),
 0,
 1
 ),
 If(
 Weekday(
 DateAdd(
 StartDates.SelectedDate,
 Value
 )
 ) = 1,
 {DayCount: 0},
 {DayCount: 1}
 )
 ),
 DayCount
 ) + If(
 Checkbox3.Value = false,
 0.5
 ) + 1 / 2
 ) - CountRows(
 Filter(
 colHolidays,
 HolidayDates >= StartDates.SelectedDate,
 HolidayDates <= EndDates.SelectedDate
 )
 )
 ))
 )
 )

 

zero.PNG

 

Can you help me with this? Thank you

Categories:
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @pword 

     

    We are doing leave calculation when varCalculationActive1 is true but on false old values retains. We need to add ",0" at the second end of the line. So please update to

    If(varCalculationActive1,
     If(
    
     Leavetype.Selected.Value = "Maternity leave",
     If(
     StartDates.SelectedDate <= EndDates.SelectedDate,
     DateDiff(
     StartDates.SelectedDate,
     EndDates.SelectedDate,
     Days
     ) + 1 - If(
     Checkbox3.Value,
     0.5
     )
     ),
     (If(
     StartDates.SelectedDate = EndDates.SelectedDate,
     Sum(
     If(
     Weekday(StartDates.SelectedDate) = 1,
     0,
     1
     )
     ) - If(
     Checkbox3.Value,
     0.5
     ),
     If(
     StartDates.SelectedDate > EndDates.SelectedDate,
     -Sum(
     ForAll(
     Sequence(
     DateDiff(
     EndDates.SelectedDate,
     StartDates.SelectedDate,
     Days
     ),
     0,
     1
     ),
     If(
     Weekday(
     DateAdd(
     EndDates.SelectedDate,
     Value
     )
     ) = 1,
     {DayCount: 0},
     {DayCount: 1}
     )
     ),
     DayCount
     ) - If(
     Checkbox3.Value = false,
     0.5
     ) - 1/2,
     Sum(
     ForAll(
     Sequence(
     DateDiff(
     StartDates.SelectedDate,
     EndDates.SelectedDate,
     Days
     ),
     0,
     1
     ),
     If(
     Weekday(
     DateAdd(
     StartDates.SelectedDate,
     Value
     )
     ) = 1,
     {DayCount: 0},
     {DayCount: 1}
     )
     ),
     DayCount
     ) + If(
     Checkbox3.Value = false,
     0.5
     ) + 1 / 2
     ) - CountRows(
     Filter(
     colHolidays,
     HolidayDates >= StartDates.SelectedDate,
     HolidayDates <= EndDates.SelectedDate
     )
     )
     ))
     ),0
    )
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @pword 

     

    Are you still having issues? Please let us know if anything needs on your post. We can help with this.

    Please mark the post as Solved If I have answered your question.
    Please give it a Thumbs Up if you find the suggestion helpful

    Thanks,
    Stalin - Learn To Illuminate

  • pword Profile Picture
    188 on at

    Thank you @StalinPonnusamy  its working now

  • pword Profile Picture
    188 on at

    hi @StalinPonnusamy, My manager wants to have a condition on my Leave System App, the user should file a leave 3 days before the startdate else the submit button was disbable if the user file a leave today or  2 days before the start date., but in emergency leave type you can file a leave any day.  Can you help me with this?

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @pword 

     

    Set the visible property of the submit button to

     

    DateDiff(Today(),StartDates.SelectedDate, Days) >= 3

     

     

    You may be setting the display mode of the submit button to edit  or disable instead of visible like below (In this case visible always true)

     

    If(DateDiff(Today(),StartDates.SelectedDate, Days) >= 3,DisplayMode.Edit,DisplayMode.Disabled)

     

     

    StalinPonnusamy_0-1635605375757.png

     


    Thanks,
    Stalin - Learn To Illuminate

     

  • pword Profile Picture
    188 on at

    Hi @StalinPonnusamy , it's working. Thank you, but how can i exclude the leave type emergnecy leave in that condition??

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @pword 

     

    If(LeaveType.Selected.Value = "Emergency Leave" || DateDiff(Today(),StartDates.SelectedDate, Days) >= 3,DisplayMode.Edit,DisplayMode.Disabled)

     


    Thanks,
    Stalin - Learn To Illuminate

  • pword Profile Picture
    188 on at

    Hi @StalinPonnusamy, Thank you , but my submit button still not visible when i choose emergency leave and file a leave today. You can file a Emergency leave any day

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @pword 

     

    To Set Visible property

    LeaveType.Selected.Value = "Emergency Leave" || DateDiff(Today(),StartDates.SelectedDate, Days) >= 3

     

    StalinPonnusamy_0-1635819828969.png

     

    To set Display mode

    StalinPonnusamy_1-1635819938850.png

     

    StalinPonnusamy_2-1635819998305.png

     

  • pword Profile Picture
    188 on at

    Hi @StalinPonnusamy , Thank you . But what if it depends on number of days of your leave.  If i want to have a vacation leave of 3 to 5 days up the condition should be enable the 3 days notice before the start day of leave. but if your vacation leave is just 2 days the condition must be false.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard