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 / Create Collection from...
Power Apps
Answered

Create Collection from textbox adding ID

(0) ShareShare
ReportReport
Posted on by 248

Hi there,

 

I have a collection from a text but I want to add an ID (CountRows or similar):

 

 

Collect(
 colCSVImport;
 RenameColumns(Split(Substitute(CSVImport.Text;" ";"");Char(10));"Result";"SerialCSV"))

 

 

The problem here I can't add the ID after split the text, or I don't know how do it.

 

Could someone help me?.

 

Thank you in advance.

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Manarjomar 

    The following formula will provide what you are looking for.

    With({_items: Split(Substitute(CSVImport.Text;" ";"");Char(10))},
     ForAll(Sequence(CountRows(_items)),
     {SerialCSV: Last(FirstN(_items, Value)).Result,
     RowID: Value
     }
     )
    )

     

    I hope this is helpful for you.

  • Manarjomar Profile Picture
    248 on at

    Hi @RandyHayes ,

     

    Work well but now I will try to understand the formula.. hehehe

     

    Only need to add the Collection :

     

    Collect(colCSVImport;
    With({_items: Split(CSVImport.Text;Char(10))};
     ForAll(Sequence(CountRows(_items));
     {SerialCSV: Last(FirstN(_items; Value)).Result;
     RowID: Value
     }
     )
    ))

     

    Many thanks again.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Manarjomar 

    Yes, the formula provided produces a table, so that can be used anywhere that you need a table.

     

    It very simply does the following:

    1) Creates a With Scoped Variable called _items and sets it to a table of records with a Result column produced by the Split function.

    2) Then the ForAll (which is a Function that is used to Produce a table), iterates over a sequence of numbers from 1 to the count of the split records in the _items variable.

    3) The second parameter of the ForAll is the record definition for records in the produced table - in this case we produce a record containing the RowID (which is just the Value of the sequence count) and the SerialCSV column - which is the result of the record at the X location in the _items table, where X is defined by the Value of the sequence count.

     

    Sorry I meant to replace the commas with semicolons for your language, but forgot to! 🙄

  • Manarjomar Profile Picture
    248 on at

    @RandyHayes 

     

    Now it's clearer, I will practice!!

     

    No worries about semicolons, I understood.

     

    Thank you for your time to explain me. 😉

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

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 379 Most Valuable Professional

#2
11manish Profile Picture

11manish 203 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard