Showing results for 
Search instead for 
Did you mean: 
Resolver I
Resolver I

Context variable not updating OnChange


I'm running into an issue where the Date/Time that I'm generating `ITime` is correctly displayed in Label1.Text when the screen shows up (OnVisible), but when changing dropdowns, from say 8:00pm to 4:00pm, ITime doesn't update until the 2nd time it's changed, back to 3:00pm, ITime = 4:00pm (previous change).



Screen1.OnVisible = UpdateContext({
IDate: DatePicker1.SelectedDate,
IHour: HourPicker1.Selected.Value,
IMinute: MinutePicker1.Selected.Value,
IAMPM: AMPMPicker1.Selected.Value,
ITime: IDate & " " & IHour & ":" & IMinute & " " & IAMPM

Label1.Text = ITime


ITime = 4/25/2018 8:00 PM


HourPicker1.OnChange = UpdateContext({
  ITime: IDate & " " & IHour & ":" & IMinute & " " & IncidentDateAMPM.Selected.Value

Label1.Text doesn't change until DatePicker1 is changed a 2nd time.


ITime = 4/25/2018 8:00 PM (OnVisible)
ITime = 4/25/2018 8:00 PM (HourPicker1 changed to 4:00 PM)
ITime = 4/25/2018 4:00 PM (HourPicker1 changed to 3:00 PM)

ITime = 4/25/2018 3:00 PM (HourPicker1 changed to 9:00 PM)


It's acting like it's a step behind updating ITime? 


Community Support
Community Support

I think that is the way how it works.

OnChange property would trigger the event when users trying to change the Dropdown Value, and please note it, the formula runs before the value changes was done, not after it.

So when the commands executing, the 


Keeps the previous value.


If you would like to keep the current value, then please just use the 

DatePicker1.SelectedDate&" "&HourPicker1.Selected.Value&": "& MinutePicker1.Selected.Value & " "&AMPMPicker1.Selected.Value




Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you Michael! 

The issue was actually that ITime can't be generated in the same UpdateContext() formula. I just did a new UpdateContext() on the next line and it worked as expected.

Helpful resources

PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,447)