Limit the number of rows visible in a table view
I have a table view on my dashboard that sorts customers by amount spent. I would like it to display only the 5 customers who made the biggest expenses.
Is it possible ? And if so, how can I do it ?
You can take your select and then use the count() and slice() functions.
let yourSelect := select.... order by expensesfieldname let cntofSelect := count(yourSelect) slice(yourSelect,cntofSelect-5,cntofSelect)
I don’t know if you had sorted your select, but if you didn’t then you can add the order by command to sort by the appropriate fieldname.
Then we get a count of records.
Then we take the last 5.
Fred I was able to get your code to work however, I forgot to include a condition. Here is the code I am using:
let yourSelect := ((select Comptes)['Total facturé'] order by 'Total facturé'); let cntofSelect := count(yourSelect); slice(yourSelect, cntofSelect - 5, cntofSelect)
I would have to condition the code like this:
let filterStart := 'Début du filtre'; let filterEnd := 'Fin du filtre'; let yourSelect := (select Comptes)[date('Première interaction') >= filterStart and date('Première interaction') <= filterEnd]; (select Comptes)['Total facturé'] order by 'Total facturé'; let cntofSelect := count(yourSelect); slice(yourSelect, cntofSelect - 5, cntofSelect)
I can't get the sorting function to work, which is essential in this specific case : (select Comptes)['Total facturé'] order by 'Total facturé'
- Status Answered
- 6 mths agoLast active