Welcome!
This community is for professionals and enthusiasts of the Genio platform.
Share your questions and challenges, and help your partners!
Linked Sum with conditions
I have a table "People" related with two other tables, "Country" and "Gender", like this : [Country] <- [People] -> [Gender].
My goal is to create a Linked Sum (SR) of table "People" in the table "Country" that matches a foreign key of "People" from table "Gender".
Thanks for some help with this issue.
Hi, Rodrigo.
Yes, what I want is to calculate the number of people by gender for each country.
The case you specified (taking into account your comment) is not solvable by a Linked Sum. A Linked Sum calculated a single result, but in your case what you are looking to calculate outputs multiple results. Furthermore, the number of results is not fixed since its dependent on the Gender table, so creating additional field and Linked Sums will not solve it either.
You will have to rely on a more complex pattern called Sum and Create Records (ST).
For this to work you will need an additional table to hold those multiple results that will combine the Country table with the Gender table and will save an output for each combination of those. Lets call it G_C (Genders per country).
It will need a foreign key to Country, and another foreign key to Gender, and a numeric field to hold the sum.
The People table will also need a foreign key to G_C
Then in the numeric field you setup a normal Linked Sum (SR) to count the people [People->1]
In the foreign key to the Country you setup a Create Record (ST) to copy the corresponding relation in the Person [Person->CODCNTRY]
In the foreign key to the Gender you setup a Create Record (ST) to copy the corresponding relation in the Person [Person->CODGENDER]
With this setup, each time you save a new Person it will check if a row in G_C already exists to hold the sum corresponding to the combination (Country,Gender) and if it doesn't it will create that record. From then on the SR will work as normal.
Its a complex pattern, not used often (a report is more common in these cases) but if you take it step by step its logical to use and to understand.
Keep Informed
About the Community
Question tools
Stats
Asked: 30/08/2019 10:01 |
Seen: 1569 times |
Last updated: 26/09/2019 17:03 |
Not sure what exactly you want to do, could you state your specific dificulty in form of a question?
It seems you want to sum the number of people in a country by gender, however that is impossible to do with one single field. That query would output multiple results, as many as there are Genders in the respective table. Is this really what you want?