web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Help with formula usin...
Power Apps
Unanswered

Help with formula using ForAll First and Split

(0) ShareShare
ReportReport
Posted on by 550

Hello community! I'm stuck on a formula that should be easy but I've a feeling I'm missing something obvious.

 

I have a collection - Attachment Collection. I want to split the DisplayName of each attachment and add the result as a Value to an existing collection. This is the AttachmentCollection 

kky1_0-1678993696659.png

I want to split the AttachmentCollection Displayname on "^" and get the value before this delimiter and add it to a second collection: 

kky1_1-1678993812612.png

I've tried versions of a formula to do this but both throw errors. I suspect my syntax is off...Also, I think this would return "Result" when I need it to be "Value" as in the above collection. 

 

 

 

Collect(colUploadMateriasTable, 
 ForAll
 (First(Split(AttachmentCollection.DisplayName,
 "^"
 ), {Result: ThisRecord.Value})
 ).Result);
Collect(colUploadMateriasTable, 
 First(
 ForAll(Split(AttachmentCollection.DisplayName,
 "^"
 ), {Result: ThisRecord.Value})
 ).Result)

 

 

 

I have this formula on the OnVisible property of my screen where the attachment control is in a form.

kky1_2-1678994150390.png

 

Alternatively, I've also tried StartsWith in my formula for a checkmark icon because I am using the collection to compare with a label value in my gallery. If there is a match, the checkmark should display as below.

kky1_0-1678994448689.png

kky1_0-1678995028354.png

 

kky1_1-1678994699811.png

 

Thank you in advance for anyone's assistance!

@kky1 

Categories:
I have the same question (0)
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @kky1,

     

    If I understand it correctly, you only want the left part of the ^ delimiter to be added within your collection?

    In this case we can actually use a Left() and Find() function to find the ^ char in your text and only give us whatever is written on the left side of that character.

     

    I have provided some comments to further explain my code:

    ForAll(
     //Loop through all display names
     ForAll(
     AttachmentCollection.DisplayName,
     //Only return what is written on the left side of the found character
     Left(
     ThisRecord.Value,
     //Find the ^ character in the text
     Find(
     "^",
     ThisRecord.Value
     ) - 1 //-1 to avoid also including the ^ char itself
     )
     ) As Main,
     //Collect the names individually
     Collect(
     colUploadMateriasTable,
     Main
     )
    )

     

    If this solves your question, would you be so kind as to accept it as a solution.

    Thanks!

  • kky1 Profile Picture
    550 on at

    Thank you @LaurensM for the quick response and awesome explanation. I'm running into a new error that Value isn't recognized. Here is a screenshot:

    kky1_0-1678995912765.png

     

  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @kky1,

     

    Could you try leaving out .Value (ThisRecord might be enough):

     

    ForAll(
     //Loop through all display names
     ForAll(
     AttachmentCollection.DisplayName,
     //Only return what is written on the left side of the found character
     Left(
     ThisRecord,
     //Find the ^ character in the text
     Find(
     "^",
     ThisRecord
     ) - 1 //-1 to avoid also including the ^ char itself
     )
     ) As Main,
     //Collect the names individually
     Collect(
     colUploadMateriasTable,
     Main
     )
    )

     

    Should that not work, try typing out ThisRecord. manually and see what Power Apps recommends.

     

    I hope this helps!

  • kky1 Profile Picture
    550 on at

    Thank you @LaurensM !! When I took out "Value" the app threw an error that it expected a Text value. Then I noticed it prompted me to choose DisplayName so I tried that and it worked! 🙂 So I will mark your response as a solution because I never would've figured this one out on my own! 🙂

     

    For anyone reading this thread, here is the final code that worked in this scenario. 

    ForAll(
     //Loop through all display names
     ForAll(
     AttachmentCollection.DisplayName,
     //Only return what is written on the left side of the found character
     Left(
     ThisRecord.DisplayName,
     //Find the ^ character in the text
     Find(
     "^",
     ThisRecord.DisplayName
     ) - 1 //-1 to avoid also including the ^ char itself
     )
     ) As Main,
     //Collect the names individually
     Collect(
     colUploadMateriasTable,
     Main
     )
    )

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard