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 / Error using IF stateme...
Power Apps
Answered

Error using IF statement in COLLECTION

(0) ShareShare
ReportReport
Posted on by 383

Hi Power Apps Community,

I am trying to create a collection of the items in a Gallery.

Issue: The values which I am trying to collect are from two controls (Radio and Text). Depending on the control used, I would like to collect the relevant data. As seen below, I have been trying to incorporate the IF statement in the Collection.

ForAll(Gallery.AllItems,
 Collect(CollectionName,
 {Field1:Title.Text,
 Field2: If('Field' = "Value", Radio.Selected.Value, TextInput.Text}));

 I would appreciate any help.

Thank you in advance.

Categories:
  • Verified answer
    SkiDK Profile Picture
    1,016 on at

    Hi @Data_Enthusiast 

    There is a mistake in your syntax. You don't close the if statement.

    ForAll(
     Gallery.AllItems,
     Collect(
     CollectionName,
     {
     Field1: Title.Text,
     Field2: If('Field' = "Value", Radio.Selected.Value, TextInput.Text)
     }
     )
    );

     

  • Data_Enthusiast Profile Picture
    383 on at

    Hi @SkiDK 

    Thank you for the response.

    When adding your update, I get the following issue:

    Data_Enthusiast_0-1602158348777.png

    Seems to not like the equal sign.

  • Data_Enthusiast Profile Picture
    383 on at

    Hi @SkiDK 

    Please ignore the previous comment. I made a mistake on my side. Your formula provided does work 😀

    I guess it does not help that I rush 😅

    Thank you for the help.

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 325

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard