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 Apps
Answered

FirstN??

(0) ShareShare
ReportReport
Posted on by

Hi,

 

If I have a column with a sortorder and use the following formula to order.

 

SortByColumns('[dbo].[SurveyQuestions]',"SortOrder")

 

How do I return a record at row 2..3.. etc  

 

Something like 

 

FirstN(SortByColumns('[dbo].[SurveyQuestions]',"SortOrder"), 2).Question

 

 

Thanks

J

Categories:
I have the same question (0)
  • v-micsh-msft Profile Picture
    on at

    Hi @Anonymous,

     

    If you would like to return a single record, we could take use of Lookup function.

    For Multiple records, function filter, search should be able to deal with that:

    Filter, Search, and Lookup functions in PowerApps

     

    So here if you would like to show the Question value of the second row from the SQL Table, we could write the formula as below:

     

    Lookup(SortByColumns('[dbo].[SurveyQuestions]',"SortOrder"), SortOrder=2).Question

    Regards,

    Michael

  • Verified answer
    CarlosFigueira Profile Picture
    on at

    There's no "indexing" function in PowerApps where you can retrieve a specific record by its position; but you can use a combination of the FirstN and Last functions to accomplish that.

     

    In your case, if you want the second item in your (sorted) list of items, you can use the following expression:

     

    Last(FirstN(SortByColumns('[dbo].[SurveyQuestions]', "SortOrder"), 2)).Question

    Can you explain what is your scenario where you want to retrieve a specific item (by position) of your data source? It would be interesting to know why you need that functionality. Thank you!

  • Community Power Platform Member Profile Picture
    on at

    Hi @CarlosFigueira,

     

    Perfect workaround. I use the indexing to return a specific row for a list of questions in a database. The table has an orderBy column however the values are not sequential.  e.g. 10 , 20 , 30  I presume this is so they can insert more later without requiring multiple updates.

     

    Cheers

    Jeremy

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