What's new

Welcome to the GSA Community!

This is the Official User Community for GE's GeoSpatial Analysis products. By registering with us, you'll be able to discuss, share and private message with other members of our Community.
Registration is currently only allowed with a personalized invitation code, which you might have received previously. If you haven't got one:
please get in touch with your GE contact person or your regional moderator(s): see FAQ.

SignUp Now!

GSA 5.2.7. Joining analytic objects by "highest number"

Björn Schaefer

Member
Confirmed GSA Customer
Joined
Oct 26, 2020
Messages
91
Hi everybody!

I'd like to solve the follwing problem, but unfortunately I have no idea, how to....

There are two classes to join by the params shown below:
1622540382458.png

This leads in some cases to multiple results, so I have to grab the right one by another parameter:

within the 1:n child class, there is a number available
1622540566835.png
and I need to select / filter the one with the highest number (in Addition to the params shown above).

Is there any easy solution for that?

Many thanks in advance...
 

Frank Pistorius

Spatial Eye
Confirmed GSA Customer
Joined
May 26, 2020
Messages
36
Hi Björn,

This is possible by using the sorting possibilities in the join collection.

I've got a simple example setup using excel files. In this case, there are two tables: main and sub.

InputData.png

From these input collections, I've created two business collections: main and sub.

These two collections are the base collections in my analysis:

Analysis.png

To show the different possibilities in setting things up, I've created three different join collections.

1. The first collection is a simple join between the main and the sub-collection with an additional field taken from the sub.
MainSub.png

This shows the repeating behaviour that you've shown in your example.

2. The second collection is a join collection, but in this case, sorting the (joined) subs for each main and only picking the first one.
MainLowestSub.png
Note that the ordering of the subs is done on the ID field and the ordering is ascending.
By indicating that only one record must be yielded of the sorted elements (for each main), this will only yield the first joined one.

3. The third collection uses the sorting, but in this case in descending order
MainHighestSub.png

In this case, the ordering is set to descending. This means that the joined subs will be sorted in descending order (with respect to ID) and 1 element of this set is taken into account.

This translates to your case by:

- set the join to multiple elements
- switch the sorting and set the expression to sort by (by using alt-down-arrow, you can open a bigger editor with IntelliSense).
- make sure to set the ordering to descending

Please find a self-contained project attached with the sample data and analysis used in this example.

Regards,

Frank
 

Attachments

  • AnalysisHighestFromSub.zip
    12.8 KB · Views: 1

chrisackland

GE - Moderator
Staff member
Confirmed GSA Customer
Joined
Jul 23, 2020
Messages
16
Grea
Hi Björn,

This is possible by using the sorting possibilities in the join collection.

I've got a simple example setup using excel files. In this case, there are two tables: main and sub.

View attachment 185

From these input collections, I've created two business collections: main and sub.

These two collections are the base collections in my analysis:

View attachment 186

To show the different possibilities in setting things up, I've created three different join collections.

1. The first collection is a simple join between the main and the sub-collection with an additional field taken from the sub.
View attachment 187

This shows the repeating behaviour that you've shown in your example.

2. The second collection is a join collection, but in this case, sorting the (joined) subs for each main and only picking the first one.
View attachment 188
Note that the ordering of the subs is done on the ID field and the ordering is ascending.
By indicating that only one record must be yielded of the sorted elements (for each main), this will only yield the first joined one.

3. The third collection uses the sorting, but in this case in descending order
View attachment 189

In this case, the ordering is set to descending. This means that the joined subs will be sorted in descending order (with respect to ID) and 1 element of this set is taken into account.

This translates to your case by:

- set the join to multiple elements
- switch the sorting and set the expression to sort by (by using alt-down-arrow, you can open a bigger editor with IntelliSense).
- make sure to set the ordering to descending

Please find a self-contained project attached with the sample data and analysis used in this example.

Regards,

Frank
Great explanation Frank!
 
Top