Dear All,
I am trying to figure out a way to display popups in a feature class based on data available in a related table. I can use FeatureSetByRelationshipName to return a feature class, but I am very confused about how to access the specific values within the feature set. For example, I have the following table where pkida is a field related to the feature class which is a point layer. I want to program a field in the point feature class to return a specific value if pkida "1" has a savings account.
@XanderBakkerI have looked at several posts where people are trying to do similar things and you have been able to clarify things, but it is proving a bit difficult to understand. I would be grateful for any help here.
Solved! Go to Solution.
var fs = FeatureSetByRelationshipName(...)
// if you clicked on a feature where pkida == 1, then only the first 3 entries
// of your example table will be in fs.
// you can do various things with that feature set:
// return the number of saving accounts
var fs_savings = Filter(fs, "Service = 'Savings'")
return Count(fs_savings)
// just return "Yes" if there is at least one "Savings" entry, "No" otherwise
if(Count(fs_savings) > 0) { return "Yes" }
return "No"
// return the sum of all savings accounts
return Sum(fs_savings, "Balance")
// return a total balance
fs_loans = Filter(fs, "Service = 'Loan'")
fs_shares = Filter(fs, "Service = 'Shares'")
return Sum(fs_savings, "Balance") + Sum(fs_shares, "Balance") - Sum(fs_loans, "Balance")
var fs = FeatureSetByRelationshipName(...)
// if you clicked on a feature where pkida == 1, then only the first 3 entries
// of your example table will be in fs.
// you can do various things with that feature set:
// return the number of saving accounts
var fs_savings = Filter(fs, "Service = 'Savings'")
return Count(fs_savings)
// just return "Yes" if there is at least one "Savings" entry, "No" otherwise
if(Count(fs_savings) > 0) { return "Yes" }
return "No"
// return the sum of all savings accounts
return Sum(fs_savings, "Balance")
// return a total balance
fs_loans = Filter(fs, "Service = 'Loan'")
fs_shares = Filter(fs, "Service = 'Shares'")
return Sum(fs_savings, "Balance") + Sum(fs_shares, "Balance") - Sum(fs_loans, "Balance")
@JohannesLindner @XanderBakker
This solution did work, though now we have run into a different but related issue. We are working with data that is in 3 layers, i.e. there is a related table to the feature class, and then another related table to the first related table, via a different ID field. It looks like this:
The original point table
the first related table, related through stopNo
The second related table, related to the first table through busNo
What we want to understand is, how can run a calculation on the second realted table through the original point layer? For example, if we wanted to know the sum of all the passengers in the buses that went through point A01, how would we do that?
When we use featuresetbyrelationshipname, using the name of the second relationship class, it reruns an empty featureset.
Can you please help me out regarding this?
In this case you have to call FeatureSetByRelationShip multiple times:
var busses_at_stop = FeatureSetByRelationshipName($feature, "BussesAtStop") // first related table
var total_passengers_at_stop = 0
for(var bus in busses_at_stop) {
var passengers_in_bus = FeatureSetByRelationshipName(bus, "PassengersInBus") // second related table
total_passengers_at_stop += Sum(passengers_in_bus, "Numpass")
}
return total_passengers_at_stop
@JohannesLindnerThanks for the reply! I will try this out for sure.