cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User
Super User

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

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...

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

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

@martinav 

I agree with @EricLott 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 @EricLott 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."

View solution in original post

3 REPLIES 3
EricLott
Level 10

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

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

Super User
Super User

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

@martinav 

I agree with @EricLott 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 @EricLott 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."

View solution in original post

Super User
Super User

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

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.

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,129)