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 / How to retain default ...
Power Apps
Answered

How to retain default value when items property is dynamically generated?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Background

I have a list on SharePoint, with two timestamp(date & time) columns, one called StartTime, and the other one EndTime. Now I have some complex validation logic behind these two timestamps (the most obvious one is EndTime>StartTime). And instead of showing the user a generic validation error text, I want to limit the input user can make so that they never end up with a validation error they have no idea about.

 

Current Situation

I have created a PowerApps form, and changed the items property of the time dropdown to a formula that only returns valid entries, like this (prettified, the actual code is a one-liner):

 

/**
* HourValue1 is the dropdown controlling the hour part of StartTime
* MinuteValue1 is the dropdown controlling the minute part of StartTime
* HourValue2 is the dropdown controlling the hour part of EndTime
* MinuteValue2 is the dropdown controlling the minute part of EndTime
*/
HourValue2.Items=Switch(HourValue1.Selected.Value, "08",["08","09","10","11","12"], "09",["09","10","11","12"], "10",["10","11","12"], "11",["11","12"], "13",["13","14","15","16","17"], "14",["14","15","16","17"], "15",["15","16","17"], "16",["16","17"], "17",["17"], "18",["18","19","20"], "19",["19","20"], "20",["20"], [""]) MinuteValue2.Items=Switch(HourValue2.Selected.Value, "",[""], "12",["00"], "17",If(HourValue1.Selected.Value=HourValue2.Selected.Value, Switch(MinuteValue1.Selected.Value, "00",["10","20","30"], "10",["20","30"], "20",["30"], [""]), ["00","10","20","30"]), "20",If(HourValue1.Selected.Value=HourValue2.Selected.Value, Switch(MinuteValue1.Selected.Value, "00",["10","20","30"], "10",["20","30"], "20",["30"], [""]), ["00","10","20","30"]), If(HourValue1.Selected.Value=HourValue2.Selected.Value, Switch(MinuteValue1.Selected.Value, "00",["10","20","30","40","50"], "10",["20","30","40","50"], "20",["30","40","50"], "30",["40","50"], "40",["50"], [""]), ["00","10","20","30","40","50"]))

The formula successfully populated valid entries into the items available in the dropdown. However, it causes the default value to be reset to the first item available, instead of retaining its old value (both Default=Parent.Default, and Parent.Default=ThisItem.EndTime). For example, if I have an existing data, <StartTime=08:30, EndTime=11:30>, upon viewing/editing of it, the dropdowns controlling EndTime actually show 08:40, simply because that's the first valid entry. So it seems that the default value somehow got refreshed/reset due to the change of items property.

 

So, the question, how can I prevent this behavior, and retain the default value when it is a valid entry?

Categories:
  • Sienna Profile Picture
    1,532 on at

    @Anonymous

    Where are those dropdowns placed? Are they in editform, gallery....? Why are you using in Default (Default=Parent.Default, and Parent.Default=ThisItem.EndTime) ?

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Sorry, turns out it's caused by different timezone being used. SharePoint by default inherit the timezone from the parent site, if not changed in "Regional Settings". But PowerApps use local time of the browser.

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard