What is the most efficient way to access a field value at the last row of a table

My expression is as follows and it works.

However I need another way to drop "any(select" expression to improve the performance.

any(select(Production Transfers[Transfer KG],[_RowNumber]=max(Production Transfers[_RowNumber])))

Solved Solved
1 2 35
1 ACCEPTED SOLUTION

@Suvrutt_Gurjar gave you some great advice, the only other thing I'd tack on here is the following.

Select() (and particularly MAXROW() ) are high computational functions that can cause issues when you've got a larger data set; so while they will work in providing you with your answer, there are other methods that might be more efficient for your system.

  • The method that I've found that works lightning fast (even with tens of thousands of records to parse through) is by using a combination of INDEX() and COUNT()
INDEX(
  Production Transfers[Transfer KG], 
  Count(Production Transfers[Transfer KG]) 
)

 Or if you need to ensure things are in the correct order (due to back-dating):

INDEX(
  OrderBy(
    Production Transfers[Transfer KG], 
    [Transfer_Date]
  ), 
  Count(Production Transfers[Transfer KG]) 
)

 Here is a video you might find helpful:

View solution in original post

2 REPLIES 2

Please post such questions in the "Q&A" section.

The expression shared by you has a multirow expression in a SELECT() that will degrade the performance.

As a better alternative you could use MAXROW() expression in a slice. Say a slice called "Latest_Transfer_Kg" with a row filter expression something like 

[Key column]= MAXROW("Production Transfers", "_ROWNUMBER")

Then the latest value of [Transfer_Kg] can be something like 

INDEX(Latest_Transfer_Kg[Transfer Kg], 1) 

Please note the slice will have only one row. So Latest_Transfer_Kg[Transfer Kg] will have only one record.

MAXROW() - AppSheet Help

 

 

@Suvrutt_Gurjar gave you some great advice, the only other thing I'd tack on here is the following.

Select() (and particularly MAXROW() ) are high computational functions that can cause issues when you've got a larger data set; so while they will work in providing you with your answer, there are other methods that might be more efficient for your system.

  • The method that I've found that works lightning fast (even with tens of thousands of records to parse through) is by using a combination of INDEX() and COUNT()
INDEX(
  Production Transfers[Transfer KG], 
  Count(Production Transfers[Transfer KG]) 
)

 Or if you need to ensure things are in the correct order (due to back-dating):

INDEX(
  OrderBy(
    Production Transfers[Transfer KG], 
    [Transfer_Date]
  ), 
  Count(Production Transfers[Transfer KG]) 
)

 Here is a video you might find helpful:

Top Labels in this Space