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 / Delegation issue: Find...
Power Apps
Answered

Delegation issue: Find minimum date from sql database

(0) ShareShare
ReportReport
Posted on by 107

Hej power apps experts,

 

My datasource is SQL server with more than 5000 rows. I have a date column knowns as 'CreatedOn'.
I want to return the minimum date and maximum date. I am not able to avoid delegation problem.

 

I have tried:
Min(sql_table, CreatedOn) - delegation issue, I guess because Min function is for Number type.

First( Sort(sql_table, CreatedOn, Ascending)).CreatedOn - delegation issue because of First function. But, source of first funtion is sorted in ascending order (without delegation issues), and I am fetching the first row - Would I ever get issues here? Theoretically it seems that this should hold.


Any better ideas to work this out? 

Can somebody help. Any help would be appreciated.
Thanks.

Okay, I found a work around but it looks too dramatic:
First( FirstN( Sort(sql_table, CreatedOn, Ascending), 1) ).CreatedOn

Categories:
  • Pstork1 Profile Picture
    69,665 Most Valuable Professional on at

    Although First() is not delegable, Sort() is.  So using First( Sort(sql_table, Created on, Ascending)).Created on will sort the table by date, return the first 500 (2,000) rows, and give you the first record.  That will reliably give you the earliest date even if the list exceeds the data row limit.  You can then get the latest date using 

    First( Sort(sql_table, Created on, Descending)).Created on

  • Verified answer
    timl Profile Picture
    37,424 Super User 2026 Season 2 on at

    @SearchingYT 

    @Pstork1 is correct in that the following will reliably give you the earliest date, irrespective of the delegation warning.

    First( Sort(sql_table, CreatedOn, Ascending)).CreatedOn

    The syntax beneath will return the earliest date more efficiently because the FirstN function will return a single record, rather than a batch of 500 (2000) rows.

    First( FirstN( Sort(sql_table, CreatedOn, Ascending), 1) ).CreatedOn

    The First/FirstN/Sort pattern is a technqiue that I have traced/described beneath, and it offers a very efficient way to return the minimum and maximum values from a table.

    http://powerappsguide.com/blog/post/how-to-return-the-last-record-from-a-table

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 139

Last 30 days Overall leaderboard