Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Problem setting default on a combobox

(0) ShareShare
ReportReport
Posted on by 714 Super User 2025 Season 1

This seems like it should be really simple but I cannot figure out the syntax.

I want to display/set the values in the combobox to what has been chosen prior. Sharepoint list for datasource. Column is a Person/Group column.

 

Items: Choices([@'BusMarket - IBC PreSurvey'].'Sales Team Information')

 

I tried setting the default both using IsBlank and IsEmpty. The intent is that if there has been a selection made in this column/field, that the values be prepopulated on the form when the form opens in Edit mode. And if there has NOT been a selection made, that the current user is populated in the combobox.

 

Here is the last attempt:

 

If(
 IsEmpty(ThisItem.'Sales Team Information'),
 User(),
 ThisItem.'Sales Team Information'
)

 

 

I'm pretty sure my problem is that IsBlank and IsEmpty both expect a single record and ThisItem.'Sales Team Information' returns a table of records. But I cannot figure out how to correct.

 

Also, should I be setting the 'Default' property or the 'DefaultSelectedItems' property.

 

Categories:
  • Verified answer
    DCHammer Profile Picture
    714 Super User 2025 Season 1 on at
    Re: Problem setting default on a combobox

    I made it work. Here are the Form, Card and Control properties used:

    Form:

    Datasource : [@'BusMarket - IBC PreSurvey']

    DefaultMode: FormMode.New

    Datacard:

    Datafield: "SalesTeamInformation"

    Default: If(EditForm1.Mode = FormMode.New,Table({DisplayName: User().FullName,Claims: "i:0#.f|membership|"  User().Email}),ThisItem.'Sales Team Information')

    ComboBox:

    Items: Choices([@'BusMarket - IBC PreSurvey'].'Sales Team Information')

    Default: If(EditForm1.Mode = FormMode.New, User())

    DefaultSelectedItems: If(EditForm1.Mode = FormMode.New, Table({DisplayName: User().FullName,Claims: i:0#.f|membership|" & User().Email}), ThisItem.'Sales Team Information')

     

  • DCHammer Profile Picture
    714 Super User 2025 Season 1 on at
    Re: Problem setting default on a combobox

    I'm really close now, I have managed to make things work to display the current data if the form is in Edit mode and not display if in New.

    EditForm1.Default = New

     

    crdSalesTeamInformation.Default = 

    If(
     EditForm1.Mode = FormMode.New,
     Table(
     {
     DisplayName: User().FullName,
     Claims: "i:0#.f|membership|" & User().Email
     }
     ),
     ThisItem.'Sales Team Information'
    )

     

    cmbSalesTeamInformation.DefaultSelectedItems = ThisItem.'Sales Team Information'

     

    So this properly displays current users in the Sales Team Information column when the form is in Edit mode.

     

    But, when the form goes into New mode, it's not putting the current user into the combobox as a choice.

  • SpongYe Profile Picture
    5,580 Super User 2025 Season 1 on at
    Re: Problem setting default on a combobox

    You are right that IsBlank and IsEmpty expect a single record, not a table.

    To check if a table is empty, you can use the CountRows function to compare the number of rows with zero.

     

    For example:

    If(
     CountRows(ThisItem.'Sales Team Information') = 0, 
     User(), 
     ThisItem.'Sales Team Information'
    )

    This will return the current user if the table is empty, or the previous selection if the table is not empty.

     

    With your code , you can use the IsEmpty function with the First function to check the first record of the table. 

    If(
     IsEmpty(First(ThisItem.'Sales Team Information')), 
     User(), 
     ThisItem.'Sales Team Information'
    )

     

    I hope this helps you solve your problem.

    If you have any questions or feedback, please let me know. Have a great day! 😊

    -----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

  • DCHammer Profile Picture
    714 Super User 2025 Season 1 on at
    Re: Problem setting default on a combobox

    That doesn't seem to work.

    DataCardValue10.Selected.'Sales Team Information'

    does not resolve. Which is a direct translation from the reply with my own control and data field names.

  • SpongYe Profile Picture
    5,580 Super User 2025 Season 1 on at
    Re: Problem setting default on a combobox

    Hi @DCHammer 

     

    Looks like DefaultSelectedItems and Choice column are referring to different columns/data.

     

    As per your example, Choice items property is 

     

    Items: Choices([@'BusMarket - IBC PreSurvey'].'Sales Team Information')

     

    Then DefaultSelectedItems could be

    comboBox.Selected.'Sales Team Information'

     

    Example

    In my example, items property is Choices(IssueTracker.SingleEvent)

    and DefaultSelectedItems is ComboBox5.Selected.SingleEvent

     

    SpongYe_1-1698250490825.png

     

     

    SpongYe_2-1698250490824.png

     

    Source: https://powerusers.microsoft.com/t5/Building-Power-Apps/DefaultSelecteditems-for-combobox-lookup/td-p/1280058

     

    If you have any questions or feedback, please let me know. Have a great day! 😊

    ----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,670 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard