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 / Need to do calculation...
Power Apps
Answered

Need to do calculations on a field in a collection

(0) ShareShare
ReportReport
Posted on by 5

Hi, 

I am having difficulty creating  new columns in a collection, which is a calculation of another existing field in a collection.

I am successfully creating the collection with an OnChange on a text field.

The textfield called (tst_inp) contains values such as : 0000-0800; 0900-1200; 2200-2400;

So I start by cereating the collection tst_gal with:

 

 

 

ClearCollect(tst_gal, Split(tst_inp_csb,";"));

 

 

 

So using the input example above the tst_gal would contain 3 rows

Value
0000-0800
0900-1200
2200-2400

 

Now I would like to loop over the 3 rows and extract the number values So I did the following: 

 

 

 

ForAll(
 tst_gal,
 AddColumns(
 AddColumns(
 tst_gal,
 "firstVal",First(MatchAll(ThisRecord.Value,"\d+"))),
 "secondVal",Last(MatchAll(ThisRecord.Value,"\d+")))
)

 

 

 

 

However when I check the collections, the tst_gal collection does not show the new columns "firstVal" and "secondVal". There are no syntax errors of course.

What am I doing wrong? Thanks you.

What am I doing wrong.

Categories:
I have the same question (0)
  • Rusk Profile Picture
    1,369 Super User 2024 Season 1 on at

    Hi @badreddm 

     

    You do not need to use ForAll for AddColumns.  Just use AddColumns and it will operate on all rows in your data source

  • Verified answer
    WarrenBelz Profile Picture
    154,399 Most Valuable Professional on at

    Hi @badreddm ,

    If you put this in the Items of a Gallery, it should show the two fields in each record

    With(
     {
     wTimes: Split(
     tst_inp_csb,
     ";"
     )
     },
     Ungroup(
     ForAll(
     wTimes As aTime,
     Table(
     {
     firstVal: First(
     Split(
     aTime.Value,
     "-"
     )
     ).Value,
     secondVal: Last(
     Split(
     aTime.Value,
     "-"
     )
     ).Value
     }
     )
     ),
     "Value"
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 85

#2
WarrenBelz Profile Picture

WarrenBelz 76 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 38 Super User 2026 Season 1

Last 30 days Overall leaderboard