Arcade pop-up

1998
8
Jump to solution
06-21-2021 07:04 AM
DEI
by
Occasional Contributor

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
Occasional Contributor

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 Esteemed 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
Occasional Contributor
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 Esteemed 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
Occasional Contributor
Please see the attached screenshots.
0 Kudos
jcarlson
MVP Esteemed Contributor

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

- Josh Carlson
Kendall County GIS
0 Kudos
DEI
by
Occasional Contributor

Oops... Maybe now?

0 Kudos
DEI
by
Occasional Contributor

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
Occasional Contributor

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