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 / About the Power Apps I...
Power Apps
Answered

About the Power Apps Index function

(0) ShareShare
ReportReport
Posted on by 134

When using the Index feature in Power Apps, is there a way to get the 2nd to 4th Index when there are a total of 5 Indexes?

I can use 'Index(Choices(Table1.ID), 1).Value' when getting a single value, but what about data in a specific range?

Categories:
I have the same question (0)
  • BhargavPatel Profile Picture
    660 Moderator on at

    @kjk4563 with regards to your example try this:

     

    LastN(
     FirstN(
     Choices(
     Table1.ID
     ),
     4
     ),
     3
    )

     

     

    You can also make it dynamic. But keep in mind that FirstN and LastN are not delegable functions.

     

    Here is an example of how to make it dynamic. 

    BF35CC50-74BD-4696-947C-38C8126903F6.GIF

     

    For items property of the combobox I used:

     

    LastN(
     FirstN(
     [
     "Item 1",
     "Item 2",
     "Item 3",
     "Item 4",
     "Item 5",
     "Item 6",
     "Item 7",
     "Item 8",
     "Item 9",
     "Item 10"
     ],
     txtIndexTo.Value
     ),
     txtIndexTo.Value -txtIndexFrom.Value+1
    )

     

  • kjk4563 Profile Picture
    134 on at

    @BhargavPatel 

    LastN(
     FirstN(
     Choices(
     Table1.ID
     ),
     4
     ),
     3
    )

     

    The above code throws an error.
    'Text value is required.'

  • VishalJhaveri Profile Picture
    1,167 Moderator on at

    This is a Prompt Response.

     

    Yes, you can use the `Filter` function along with the `Range` function to achieve this in Power Apps. Here's how you can get the values of the 2nd to 4th indexes when there are a total of 5 indexes:

     

    Filter(Choices(Table1.ID), Range(1, 3).Contains(IndexOf(Choices(Table1.ID), Value)) ).Value

     

    Let me explain this:

    1. `IndexOf(Choices(Table1.ID), Value)` returns the index of the specified value within the choices.
    2. `Range(1, 3)` creates a range from 1 to 3, representing the indexes from the 2nd to 4th.
    3. `Filter` function is used to filter the choices based on the condition specified in the `Range`.

    This will give you the values corresponding to the 2nd, 3rd, and 4th indexes from the choices in `Table1.ID`.

  • kjk4563 Profile Picture
    134 on at

    @VishalJhaveri 

    There is an error in your code.
    Contains are not available.
    Please correct it.

  • Verified answer
    iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    Regarding the errors in their formula: Range and IndexOf are not Power Apps functions - please ignore any AI prompt responses provided to you now and in future, most of the AI models are not good at Power Apps or Power Automate.

     

    To answer your question

    To get rows from a table that have an ID of between 2 to 4 you can use:

    Filter(Table1, ID >=2 && ID <=4)

     

    image.png

     

    However, this formula is not delegable, so always ensure whatever data you are pointing your at is already trimmed to under 2000 records.

     

    Cheers,

    Sancho

  • BhargavPatel Profile Picture
    660 Moderator on at

    @kjk4563 You need to use either a gallery control, a combobox, a dropdown control... a control that displays an Array or a Table, because you are bringing in more than one value. 
    On the other hand, if you want to combine all the values in one field and use a Text Input or Label you will have to merge all the values first. That will look something like this:

    Concat(
    LastN(
     FirstN(
     Choices(
     Table1.ID
     ),
     4
     ),
     3
    ),ID, // If ID doesn't work change this to Value
     "," // You can replace "," with any other separator
    )



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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard