Select to view content in your preferred language

Arcade: Return first five records?

596
2
Jump to solution
10-13-2023 08:07 AM
ArmstKP
Regular Contributor

Can someone give me an example Arcade expression that returns the first five (or whatever #) of records?

Thanks!

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

You can use the Top function to do this. The example in the documentation shows how to get the top 5 features with the highest population with the addition of the OrderBy function.

Top( OrderBy($layer, 'POPULATION DESC'), 5 )

 

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

You can use the Top function to do this. The example in the documentation shows how to get the top 5 features with the highest population with the addition of the OrderBy function.

Top( OrderBy($layer, 'POPULATION DESC'), 5 )

 

JoePlattner
New Contributor III

I feel like I'm missing an important step I'm hoping someone can help point me in the right direction.

I'm using the new map viewer in ArcGIS Enterprise Version 10.9.1 

In the expression builder for the pop up I've included code just like the above solution. I test it in the expression builder and it looks fine in that it returns the number of records  sorted the way I want. I then save the expression.

When I test my change on my web maps however, the pop ups continue to show all the records not just the top ones. Should I be referencing the expression in the body of the pop up text? I tried that but it doesn't do anything, or I'm just not doing it correctly. Thank You!

JoePlattner_1-1703883901005.png

 

 

0 Kudos