Arcade pop-up

1250
8
Jump to solution
06-21-2021 07:04 AM
Labels (2)
DEI
by
New Contributor III

Hi all,

I'm trying to use an Arcade expression in my web map pop-up to list the most current inspection reading for a point.  I have a set of location points with a related 1:M inspection table which includes numerous readings per point (with dates) recorded over the last several months. This is what I have:

var Ra=(FeatureSetByRelationshipName($feature,"Bal2021"));
var Rb=Reverse([Ra]);

return First(Rb);

Test returns the entire array in chronological order. Can anyone please suggest how I could display just the most current reading?

0 Kudos
1 Solution

Accepted Solutions
DEI
by
New Contributor III

In case anyone else may need it, I was able to figure out a solution by following along with this post and making some modifications. Here's what I ended up with:

var Ra = OrderBy(FeatureSetByRelationshipName($feature,"Bal2021"), "Date_Time DESC");

var cnt = Count(Ra);

if (cnt > 0) {

var Rb = First(Ra).RaDe;

} else var Rb= "";

return Rb;

View solution in original post

8 Replies
jcarlson
MVP Notable Contributor

Reverse returns an Array. What you probably want is OrderBy, which will return a FeatureSet. Calling First on the FeatureSet will give you the individual features.

 

var Ra = FeatureSetByRelationshipName($feature, "Bal2021");
var Rb = OrderBy(Ra, 'your-date-field DESC');

return First(Rb);

 

Also, this will just return a single Feature. If you're looking for a reading value, you would need to access that specifically.

First(Rb)['reading-value-field']
- Josh Carlson
Kendall County GIS
0 Kudos
DEI
by
New Contributor III
That was fast – thanks!

I tried your suggestion but the Test returns the first reading from
January. I would like to display the last reading from June. I think what
I’m looking for is something like a ‘Last’ or ‘Reverse’ function to call on
the FeatureSet.
0 Kudos
jcarlson
MVP Notable Contributor

Hm. Could you paste a sample of the Ra FeatureSet? And also the Rb FeatureSet you're getting when you attempt to sort it?

- Josh Carlson
Kendall County GIS
0 Kudos
DEI
by
New Contributor III
Please see the attached screenshots.
0 Kudos
jcarlson
MVP Notable Contributor

I don't see any. You can paste images directly in your message, too.

- Josh Carlson
Kendall County GIS
0 Kudos
DEI
by
New Contributor III

Oops... Maybe now?

0 Kudos
DEI
by
New Contributor III

In case anyone else may need it, I was able to figure out a solution by following along with this post and making some modifications. Here's what I ended up with:

var Ra = OrderBy(FeatureSetByRelationshipName($feature,"Bal2021"), "Date_Time DESC");

var cnt = Count(Ra);

if (cnt > 0) {

var Rb = First(Ra).RaDe;

} else var Rb= "";

return Rb;

DEI
by
New Contributor III

I'm trying to display quarterly inspection results in my pop ups but it's proving to be more difficult than I thought. Here's an example:

var tbl = Orderby(FeatureSetByRelationshipName($feature,"Day10Rem"), "Rem10Date");
var tbc = OrderBy(FeatureSetByRelationshipName($feature,"Day10Rem"), "Rem10Conc");
var Qc = IIf(tbl >= Date(2021,6,1) && tbl < Date(2021,10,1), "Rem10Conc", "");
return Qc

Could anyone please point me in the right direction or offer suggestions?

0 Kudos