Showing results for 
Search instead for 
Did you mean: 
Level 10

Re: Gallery Default property type/format?

I have created an idea for the Reset property of galleries.  Please add your kudos to it, thanks.

Level 10

Re: Gallery Default property type/format?

I have edited the above post, now the button always resets the selection to the second default record in the Default property If statement.  @lifelongjourney does this resolve your need?

Level 8

Re: Gallery Default property type/format?



I see what you are trying I think.  So the first record with todays date and your ID is what you want default to take you to, yes?


In that case, and this applys anytime a function takes an expression, you should be able to modify it as follows:


LookUp(roster_on_call, Date=Today() && ID=currentUserID)


the && above is a logical(boolean) AND which requires that both expressions result to true. This should take you to that record when you start the application. 


Meneghino is right though, once you manually select something, the default no longer works until you update it. Using a button would be a good way to do that, but you can basically use any event driven property of any control to perform it as well. 


Hope that works for ya!

Re: Gallery Default property type/format?

@Meneghino and @TschoofBAHthanks for your responses, you've both moved further forward than I can get. @Meneghino, the second item in your "bearing in mind" list was:

2. When the app is started, the gallery will show the Default item and it will be selected

This is currently not happening. This is the most critical for me. if I can have a Today button that resets the gallery back to the default, that'd be great, but this relies on the Default property working in the first place, which it isn't for me (yet!).


Maybe it's because the data source (a SharePoint list) has Lookup columns? This is the spec of the used columns:


DataSource = 'On Call Roster', a SharePoint list

  • Begin (Date)
  • End (Date and Time)
  • On Call (Lookup to external list "On Call Staff" - Name (Single line of text))
  • On Call:Mobile (Lookup to external list "On Call Staff" - Mobile (Single line of text))
  • ID (built-in)

NB: I don't have access to the list settings, so I can't unify the column settings for Begin and End


Gallery control = galRoster

galRoster.Items = 'On Call Roster'

galRoster.Default = First(Filter('On Call Roster', DateDiff(Today(), DateValue(End, "en-US"), Days) > 0))


I also have a textbox control, lblCurrentRosterID, which displays the current ID, just to reassure me that I am getting the correct ID

lblCurrentRosterID = "CurrentRosterID: " & First(Filter('On Call Roster', DateDiff(Today(), DateValue(End; "en-US"), Days) > 0)).ID


If this is another Lookup support issue in PowerApps, will be very frustrated...

Level 10

Re: Gallery Default property type/format?

Hi @lifelongjourney thanks for being so specific with your questions.


There are a few reasons I can think of why the Default may not be working, so let's try a simple test.


What happens if you simply do this?

galRoster.Default = Last ('On Call Roster')

Does the app open up with the last item showing and selected? (instead of the first one showing and nothing being selected)


Also, just to make double sure all is working, I would have another text box with .Text = galRoster.Selected.ID


This should show blank on app startup if Default is not working as expected, otherwise it should show an ID (in our test the ID of the last item)

Level 10

Re: Gallery Default property type/format?

PS Also try this


Create a button with .OnSelect = UpdateContext({ResetVar = true}); UpdateContext({ResetVar = false})


Set galRoster.Default = If(ResetVar, First('On Call Roster'), Last('On Call Roster'))


See if the button manages to force selection of the last item.  Please let me know.

Re: Gallery Default property type/format?

@Meneghino great suggestion for follow up.


I changed galRoster.Default to Last ('On Call Roster') and setup lblGallerySelectedID.Text = galRoster.Selected.ID as recommended.


The first one shows nothing being selected, and the textbox shows blank on app startup.


I liked your button idea, I had a slightly different take and created two buttons.

ButtonTrue.OnSelect = UpdateContext({ResetVar: true})

ButtonFalse.OnSelect = UpdateContext({ResetVar: false})

Before clicking either button, I would select a different entry, for example 17.


Both ButtonTrue and ButtonFalse behaved in the same way. If a button click changed the ResetVar from its previous value, the lblSelectedRosterID would be blank. I then select entry 17, and clicked the same button again. This of course did not change the ResetVar. lblSelectedRosterID stayed at 17. Same for the third and fourth clicks etc. Then if I click the other button, the loop starts again.


In other words, not even First('On Call Roster') is working, let alone Last().    😞


What else you got in mind?

Level 10

Re: Gallery Default property type/format?

Well, here is one suggestion to see if the issue is to do with data retrieval.
Create a button with OnSelect = ClearCollect(LocalRoster, 'On Call Roster')
Substitute LocalRoster for 'On Call Roster' in all the above gallery properties etc. and see what happens. You need to press the new button once to load the collection first, of course.
If this also does not work, I will come bck to it tomorrow and do some tests.

View solution in original post

Re: Gallery Default property type/format?

OMG this worked! I've refactored my code back to my original functions and it's working! Thankyou @Meneghino!

Level 10

Re: Gallery Default property type/format?

Helpful resources


Power Apps Super User Class of 2020

Check it out!


New Badges

Check it out!


Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020


Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,293)