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 / Split - Accessing spec...
Power Apps
Answered

Split - Accessing specific row (by index)

(2) ShareShare
ReportReport
Posted on by 543

I have a comma separated list which I split into a table with the Split() function. But I'm not certain how I can access a row directly by index? Something like this would be logical (where CurrentIndex is a variable somewhere else in the screen):

 

Split(AxisXLabels; ",")[CurrentIndex]

 

Any advice?

Categories:
I have the same question (0)
  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    Currently there is no function to access directly an item by a specific index - you can consider creating a new feature request in the PowerApps Ideas board for this.

     

    Notice that you already can do that, using a pair of FirstN and Last functions: to access the N-th item in a table, you can use the following expression:

    Last(FirstN(table, N))

    In your case, you can get the value as

    Last(FirstN(Split(AxisXLabels; ","); CurrentIndex))
  • JohnP Profile Picture
    543 on at

    Thanks for the workaround 🙂 I did a LookUp to work around this, but your idea is better/shorter for my use.

     

    Actually someone already proposed an index based approach to collection/tables and it was declined:

     

    https://powerusers.microsoft.com/t5/PowerApps-Ideas/Collection-indexer-Collection-index/idi-p/2591

  • NoumanQ Profile Picture
    35 on at

    Thanks for the solution. Seeminly complex problem with a simple solution. Thanks 

  • kbirstein1 Profile Picture
    130 on at

    I don't understand this, can someone give a complete example? I have a collection that has one column and four rows. The column is called "ID", so it looks like this:

    ID
    2
    8

    10

    15

     

    I would like to access the value in the third row, 10. However, this syntax:

    Last(FirstN(colLabelChangeIDs,2))

    does not work. The error says: 
    "The property expects text values. But this rule produces incompatible record values".

     

    I have seen this error a lot and understand that it has to do with records vs. single values. 

     

    However, the description of "FirstN" is so laughably inadequate in the Microsoft "documentation" it's impossible to understand how it works.

     

     

  • CarlosFigueira Profile Picture
    Microsoft Employee on at

    If you have that expression in a Label, then you need to access the ID property of your collection:

    Last(FirstN(colLabelChangeIDs,2)).ID

    Notice that this will show you the value in the second row, not the third one (as the first element has index 1). To show the third ID from your collection (i.e., the number 10), you'd use this expression:

    Last(FirstN(colLabelChangeIDs, 3)).ID

    Hope this helps.

  • MichelH Profile Picture
    401 on at

    I notice this doesn't work for me.

    I tried to pull appart a string   "69, 85, 101, 0.8"  to feed the parts into the RGBA funtion to color a label alike.

     

    To get something usable, I had to add the .Result and use the Value function, even though the strings comming out of the Split seemed appropriate input. 

     

    RGBA(
    Value( First( Split( FocusBorder.Text,",") ).Result ),
    Value( Last( FirstN( Split( FocusBorder.Text,","), 2) ).Result ),
    Value( Last( FirstN( Split( FocusBorder.Text,","), 3) ).Result ),
    Value( Last( Split( FocusBorder.Text,",") ).Result )
    )

     

    Thanks for the  Last( FirstN( array , N) )   trick!!

  • CalfordMath Profile Picture
    131 on at

    Brilliant workaround! @CarlosFigueira  Thanks.  Works for my needs.


    Last(FirstN(table, N))

     

  • jayprakash Profile Picture
    12 on at

    I have done By this Logic

    Select(Parent);RemoveIf(ProductList, Index = Gallery2.Selected.Index);

     

    Clear(collection2);

    ForAll(ProductList,
    Collect(collection2,
    {
    Index: CountRows(collection2)+1,
    Comments: Comments,
    SalesPrice: SalesPrice,
    Discount: Discount,
    Quantity: Quantity,
    Height: Height,
    Width: Width,
    Color: Color,
    ProfileSet: ProfileSet,
    Product: Product,
    Group: Group
    }
    )
    );
    Clear(ProductList);
    ForAll(collection2,
    Collect(ProductList,
    {
    Index: Index,
    Comments: Comments,
    SalesPrice: SalesPrice,
    Discount: Discount,
    Quantity: Quantity,
    Height: Height,
    Width: Width,
    Color: Color,
    ProfileSet: ProfileSet,
    Product: Product,
    Group: Group
    }
    )
    );
    Set(ValueToIncrement, CountRows(ProductList));

    wrote: -Jayprakash Birla

  • IvoYanWL Profile Picture
    8 on at

    Now there's the Index function:

    Index(Split(myString, delimiter), 1) - returns a row/record at index 1;

    Index(Split(myString, delimiter), 1).Value - returns the value/substring of the row/record at index 1;

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
WarrenBelz Profile Picture

WarrenBelz 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard