Page 1 of 1

Query on occupations

Posted: 15 Nov 2019 15:44
by Verkadej
I am running a query on occupations with the following colums:
- Name
- Occuption
- Occupation Date
- Occupation Place

Where a person can have more than one occupation (as well at the same time as sequential), the result of above query gives however no more than one result for each person.

Being a new user, perhaps I make a silly mistake, but some advise in finding it would be very helpfull.

Re: Query on occupations

Posted: 15 Nov 2019 16:03
by davidf
Welcome to FHUG

Are you running a query on Individuals or Facts?

I think you need to select "Facts" in the General Tab
Then in the Rows Tab "Excluded Unless =FactLabel(%FACT%) matches "Occupation"

That works for me

Re: Query on occupations

Posted: 15 Nov 2019 16:12
by tatewise
Welcome to the FHUG.

Yes, there are some key features of Queries that trip up newcomers.

With Individual type Queries the Result Set only ever has one row per Individual record.
So, to show more than one fact such as Occupation there must be a Column for each one.
Thus, as well as %INDI.OCCU[1]% there must be Columns for %INDI.OCCU[2]%, %INDI.OCCU[3]%, etc, etc, for the Occupation fact instances [1], [2], [3], et seq.

That becomes tedious and produces a very wide Result Set to cope with many facts, which is where the Fact type Query comes into its own, that has one row per Fact in the Result Set.
See the FH command View > Standard Queries > All Facts (and All Events) for example.
Click on the Fact Type column heading to sort into order and all the Occupation facts will be listed together.

In the fhugdownloads:contents:query_all_facts_filter_by_date_label_or_text|> Query:Fact ~ All Facts Filter by Date, Label, or Text there are custom examples such as All Facts Filter by Label that with the Label set to Occupation will list just the Occupation facts.

See how_to:creating_a_query|> Creating a Query for more details under Query Types.

As a newcomer I advise you also study how_to:key_features_for_newcomers|> Key Features for Newcomers.

Re: Query on occupations

Posted: 15 Nov 2019 17:19
by dewilkinson
As a matter of interest I have chosen to avoid this complication for occupations by just having one undated Occupation Fact per individual e.g. "agricultural labourer then a yeoman". The dates for these entries will appear in the Fact note sentence that gave rise to them, e.g. census, marriage, baptism etc records.

Re: Query on occupations

Posted: 15 Nov 2019 17:28
by tatewise
OK, but it is not practical to adopt that for all multiple facts, such as Census and Marriage events.
So the Fact Query approach is still needed for those.
It is also more difficult to search for Date related facts if not using the Date field.
How do you cope with someone who had say a dozen different Occupations as that would be a long list in the value field?

Re: Query on occupations

Posted: 15 Nov 2019 17:54
by dewilkinson
I know that approach doesn't work for other things like census that have to have dates. For multiple occupations I record them in the single record such that it forms a reasonable sentence in reports, which is my ultimate aim. I think having multiple entries for occupations (also separate Residence Facts for census's etc.) are unnecessary as the detail is in Fact and they lead to tedious reports. It is personal choice for the way I wish to present my data. Below is an example of the opening paragraph for my grandfather. Dates for those occupations will appear later on in the entry from which they are derived.
Capture.JPG
Capture.JPG (29.06 KiB) Viewed 4914 times

Re: Query on occupations

Posted: 15 Nov 2019 18:31
by Verkadej
Getting a step closer with the All Facts Filter approach. A remaining question is how I can combine that with criteria for the (occupation)Place. More specifically, I would only want to see occupations related to an occupation_place starting with #

The background is that I make a study of how a limited number of families ruled nearly all companies in a specific region during the 19th century. Therefore I (ab)used the occupation_place for entering the company name, preceeded by a "#".

Any suggestions?

Re: Query on occupations

Posted: 15 Nov 2019 19:07
by tatewise
There are many examples in fhugdownloads:queriesfact|> Downloads and Links ~ Query Type: Fact.

In particular fhugdownloads:contents:list_baptisms_and_burials_for_specific_places|> Query:Fact ~ List Baptisms and Burials for Places is very similar to your requirement.
Just use Occupation instead of Baptism/Burial in the =FactLabel(%FACT%) filter.
Use begins with instead of contains in the %FACT.PLAC% filter.

Re: Query on occupations

Posted: 16 Nov 2019 07:57
by Verkadej
Thank you, Mike, that brought the result I was after. Meanwhile found the topics "Understanding Data References" and "Understanding Functions" of which I hope that they will guide me further.