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 / If statement with Mult...
Power Apps
Answered

If statement with Multiple conditions not working

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi all,

 

I have a form (see first image below) with three choices (Overview, Strategies, Recommended Participants). I want the DefaultSelectedItems in the combobox to pre-fill based on whether other fields in the form are selected so I'm using the Not(IsBlank() formula. I've tested each of the formulas individually and they work fine (the appropriate value gets pre-filled), however, when 2 or more values are selected are the first value is selected - in this case it's always Overview.

 

How do I make it so that if 2 values are selected, 2 are pre-filled, or 3 are selected and 3 are prefilled.

 

Thanks!

 

mccardj_1-1643835529326.png

mccardj_0-1643835486638.png

 

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Please consider changing your DefaultSelectedItems property Formula to the following:

    Filter(
     [If(!IsBlank(DatCardValue10.Text), "Overview"),
     If(!IsBlank(DataCardValue8.Selected.Value), "Strategies"),
     If(!IsBlank(DataCardValue7.Selected.Value), "Recommended Participants")
     ],
     !IsBlank(Value)
    )

     

    In your original formula you were performing a !IsBlank function on a table.  SelectedItems is a table of records.  So if you are trying to determine if something is or is not selected, then performing the !IsBlank function on the single record (.Selected) is all you need.

     

    I hope this is helpful for you.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Brilliant! That worked perfectly! Thanks so much @RandyHayes 

     

    When I tried to add the multiple If statements it didn't originally work for me, is it the [] brackets that makes the difference?

     

    Thanks again

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Well, the square brackets just denote a table.  When you use them, PowerApps will generate a table with a Value column.

    The formula is equivalent to the following:

    Filter(
     Table(
     {Value: If(!IsBlank(DatCardValue10.Text), "Overview")},
     {Value: If(!IsBlank(DataCardValue8.Selected.Value), "Strategies")},
     {Value: If(!IsBlank(DataCardValue7.Selected.Value), "Recommended Participants")}
     ),
     !IsBlank(Value)
    )

     

    So the answer is yes and no.  Yes, you needed to provide a table to the DefaultSelectedItems property in order to have multiple selections.  In your formula, you were only ever going to provide one record - so only one item would have ever been selected.

    But, No, just putting what you had in square brackets would not have resolved anything.  The records within the table would have needed to be specified properly.  And then you would always want to filter out the blank records, or it will screw up the selections.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you for explaining it to me, it makes sense - now I know what to do for next time!

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
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard