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 / Trying to do an if() s...
Power Apps
Answered

Trying to do an if() statement in a ForAll(Collect()) statement

(0) ShareShare
ReportReport
Posted on by 3,347

I need an if() condition in a ForAll(Collect()).  Simple as this:

 

 

ForAll(KDL_Data_All,If(LookUp(Combine_All,PartNumber=KDL_PartNumber,PartNumber)=Blank(),

 Collect(Combine_All,{
 PartNumber:KDL_PartNumber,
 If(LookUp(ACCT_Data_All,ProductID=KDL_PartNumber,Title)=Blank(),AcctDesc:"<NO ACCTIVATE>"),
 KDL_Desc:KDL_Title,
 MD_Description:"<NO_MDL>"})
 
 )
)

 

 

I'm guessing I'll have to wrap an If() around Collect() instead??  I'd rather only have the one  statement, but I guess it will do...

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    **Ran a test, this solution didn't work

  • Verified answer
    mdevaney Profile Picture
    29,991 Moderator on at

    @martinav 

    I agree with @Anonymous that the current code will not work.  This is because the field names in Collect (i.e. AcctDesc) cannot conditionally exist.

     

    My idea is always include AcctDesc and use the IF statement to control what is written to the field.

    ForAll(KDL_Data_All,If(LookUp(Combine_All,PartNumber=KDL_PartNumber,PartNumber)=Blank(),
    
     Collect(Combine_All,{
     PartNumber:KDL_PartNumber,
     AcctDesc: If(LookUp(ACCT_Data_All,ProductID=KDL_PartNumber,Title)=Blank(),
     "<NO ACCTIVATE>",LookUp(ACCT_Data_All,ProductID=KDL_PartNumber,Title)),
     KDL_Desc:KDL_Title,
     MD_Description:"<NO_MDL>"})
     )
    )

     

    Can you please give this a try?  I believe it would be faster for you or @Anonymous to do the test since you already have it setup.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • martinav Profile Picture
    3,347 on at

    Huh, strange.  That is exactly what I was trying to do.  I must have been a parenthesis off or something.  Not sure what happened.  That worked fine, as it should have!

     

    Thanks 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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard