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 / Adding two rows to gal...
Power Apps
Answered

Adding two rows to gallery (table) with one IF-ELSE statement

(0) ShareShare
ReportReport
Posted on by 74

I'm having an issue with my Power App. I have a button with an IF statement that checks if a certain TextField is blank or not. If it is, it adds a single row to the Gallery which I'm using instead of a DataTable. If it's not Blank, then it adds two rows.

 

Something like this:

 

If( [logic test] IsBlank(OptionalField); [if true] Collect(colTable; {RequiredField1: RequiredField1.Text; RequiredField2: RequiredField2.SelectedDate; RequiredField3: RequiredField3.Text); [if false] Collect(colTable; {RequiredField1: RequiredField1.Text; RequiredField2: RequiredField2.SelectedDate; OptionalField: OptionalField.Text) And Collect(colTable; {RequiredField1: RequiredField1.Text; RequiredField2: RequiredField2.SelectedDate; RequiredField3: RequiredField3.Text))

 

However this doesn't seem to work. How can I do this? I appreciate any reply. Thank you.

Categories:
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @CadelDev 

    Please consider changing your Formula to the following:

    If(IsBlank(OptionalField.Text); 
    
     Collect(colTable; 
     {RequiredField1: RequiredField1.Text; 
     RequiredField2: RequiredField2.SelectedDate; 
     RequiredField3: RequiredField3.Text
     }
     ); 
    
     Collect(colTable; 
     {RequiredField1: RequiredField1.Text; 
     RequiredField2: RequiredField2.SelectedDate; 
     OptionalField: OptionalField.Text
     };
     {RequiredField1: RequiredField1.Text; 
     RequiredField2: RequiredField2.SelectedDate; 
     RequiredField3: RequiredField3.Text
     }
     )
    )

     

    I hope this is helpful for you.

  • CadelDev Profile Picture
    74 on at

    Oh, so that's how it works. That worked! Thank you very much!

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

Last 30 days Overall leaderboard