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 / DefaultSelectedItems a...
Power Apps
Answered

DefaultSelectedItems and Item property in conflict

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi All

 

Hopefully someone can help me with some formulas

I have 3 ComboBoxes on my form with formulas in the ITEM propery to filter/sort the available cBox options:

 

1. The 'Supplier' cBox has this formula to filters to distinct results only:

Distinct('[dbo].[SupplierServices]',Supplier)

 2. The 'Goods/Service cBox has a formula to filter results by what's in the first cBox

Filter('[dbo].[SupplierServices]',Supplier=ComboBox1.Selected.Result)

3. The Employee cBox has a formula to sort the employee names into alphabetical

Sort('[dbo].[StaffRegister]'.InitialSurname,InitialSurname)

But....
The problem is if I paste these formulas into the ComboBox ITEM properties it breaks my DefaultSelectedItems?

And I need the DefaultSelectedItems, so that when the user goes back to edit a record, their previous selection is still there, otherwise they would have to select all 3 again before saving

Am I placing these formulas in the wrong place?

I can believe MS would make you chose between having a DefaultItemsSelected or sorting/filtering would they?

Any advice would be appreciated

Regards

Vicky

DefaultSelectedItem2.png
Categories:
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    ComboBox 3 is now sorted, thanks to @KroonOfficeSol suggestion in my old post
    J
    ust 1 and 2 that are still problematic

  • Verified answer
    KroonOfficeSol Profile Picture
    587 on at

    @Anonymous

     

    The first is wrong. 

    On FirstCombo.Items do this:

    Distinct(MyTable,MyGroupName).Result

    This wil return a one column table off text values.

     

    The DefaultSelectedItems is a little strange. You should say this should be just the textstring, but this didn't seem to work. So I tried something else and this worked. So do on FirstCombo.DefaultSelectedItems

    LookUp(Distinct(MyTable,MyGroupName).Result, Result = "MySearchString")

     

    The second one should then work, because the first is fixed and the ComboBox1.Selected.Result will give a value for the condition part off the Filter(). Then you do a lookUp() for the DefaultSelectedItems, same as on the third.

     

    Hope this helps.

     

    Paul

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @KroonOfficeSol I can't thank you enough!
    I was starting to worry that I'd be showing the boss a very janky app come Monday
    But all 3 ComboBoxes are working beautifully now, with the formulas to sort/filter! Smiley Very Happy

    The only thing left that I'd like to do (and it's not the end of the world if I can't) is put an IF statement on that Employee combo DefaultSelectedItems

    If the form is in edit mode, get the employee name on that row of the MobilePOLog table: 

    If(EditForm1.Mode in [0,2], LookUp('[dbo].[MobilePOLog]', PONumber = ThisItem.PONumber))

    Else if the form is in new mode, use the current users email address to look up their name on the StaffRegister table:

    LookUp('[dbo].[StaffRegister]',Email = User().Email, Employee)

    But when I put them together it doesn't work

    If(EditForm1.Mode in [0,2], LookUp('[dbo].[MobilePOLog]', PONumber = ThisItem.PONumber),
    LookUp('[dbo].[StaffRegister]',Email = User().Email, Employee))


    Thanks again, even without this bit you have already saved my bacon!
    V

     

     

    Dodgy IF Statement.png
    All Combos Working.png
  • KroonOfficeSol Profile Picture
    587 on at

    @Anonymous

     

    You are using another entity than you do in the items, so no wonder if it doesn't work.

     

    Maybe you could try to do this at the Combo.Items attribute:

    If(EditForm1.Mode in [0,2], ShowColumns('[dbo].[MobilePOLog]', "EmployeeName"),
    ShowColumns('[dbo].[StaffRegister]', "EmployeeName"))

    I wouldn't know if the combo digs the switch in datasource without issues, so just try.

    This will work when the "Employee" is the samen. If not then you maybe also should change the Datacard.Update attribute. Lets say the first gives back a field/attribute called PersonName then use like this:

    If(EditForm1.Mode in [0,2], "PersonName", "EmployeeName")

    In this case I presumed your datacard need text for the update. If this is different you should tweak it a little bit.

     

    Hope this helps.

     

    Paul

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 405 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 368

#3
WarrenBelz Profile Picture

WarrenBelz 244 Most Valuable Professional

Last 30 days Overall leaderboard