cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
tom_garvin Advocate II
Advocate II

Select top n from Azure SQL Databasee

I have an app which works with an Azure SQL Database.

 

We have a history screen which is intended to list the most recent incidents recorded in the database.

 

I have an expression which sorts the results, latest at top (i.e. descending).

 

I do not know how to limit the number of database records returned, which will certainly be to much for a non-delagable query.

 

I can create a SQL View, but I'd prefer to keep it clean within PowerApps.

 

In other development tools, I'd use a pass-through query.

 

Or I'd use a paged control and let the results be sent in chunks, with most users only needing the first n results.

 

Looking for suggestions on how to approach a solution.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: Select top n from Azure SQL Databasee

Hi @tom_garvin,

 

Please try to use FirstN function to return the last set of records of a table.

 

For your scenario, you could take the following function for a reference:

FirstN(SortByColumns(Filter(Testing2,StartsWith(Title,TextInput1.Text)),"Created",if(SortDescending1,Ascending, Descending)),10)

 

Please have a try with it and feel free reply if you need more help.

 

Besides, please post PowerApps related issues on PowerApps forum so that you could get the most qualified answers.

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Community Support
Community Support

Re: Select top n from Azure SQL Databasee

Hi @tom_garvin,

 

Please try to use FirstN function to return the last set of records of a table.

 

For your scenario, you could take the following function for a reference:

FirstN(SortByColumns(Filter(Testing2,StartsWith(Title,TextInput1.Text)),"Created",if(SortDescending1,Ascending, Descending)),10)

 

Please have a try with it and feel free reply if you need more help.

 

Besides, please post PowerApps related issues on PowerApps forum so that you could get the most qualified answers.

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Administrator
Administrator

Re: Select top n from Azure SQL Databasee

Hello, @tom_garvin!

 

Have you had an opportunity to apply @v-yamao-msft‘s recommendation to adapt your Flow? If yes, and you find that solution to be satisfactory, please go ahead and click “Accept as Solution” so that this thread will be marked for other users to easily identify!

 

 

Thank you for being an active member of the Flow Community!

 

-Gabriel

Flow Community Manager

-Gabriel
Microsoft Power Automate Community Manager
Are YOU a member of your local Power Automate User Group?
Fill out This Form to claim your Community User Group Member Badge!
tom_garvin Advocate II
Advocate II

Re: Select top n from Azure SQL Databasee

Thank you, Mabel. I got lost on the way to the PowerApps forum, sorry Smiley Indifferent

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Users online (7,925)