Page 3 of 3

Re: Tutorial on Queries

Posted: 11 May 2019 08:55
by E Wilcock
Mike, I have been using your Fact queries a lot.
Maybe even when I dont need to and a person query would work.
The names at the moment come sorted by forename. The column is
=GetRecord(%FACT%)

Is there any way of editing this so I can sort by surname? If necessary adding the forename in another column?
I am sorry if I have asked this before. Searching suggests that I have not.

It is not a major problem. But when working down a long list of people to see who is there, on line databases tend to order by surname.

Re: Tutorial on Queries

Posted: 11 May 2019 09:28
by tatewise
See how_to:understanding_expressions#fact_name_fields|> Understanding Expressions > Examples > Fact & Name Fields towards end where it offers two expressions that "List in Surname order with Surname first/last"

Note that for Family records that will list the name of the Husband and his Wife is not listed.
To get the wives, replace MALES_FIRST by FEMALES_FIRST in either expression.

Re: Tutorial on Queries

Posted: 11 May 2019 16:44
by E Wilcock
Mike, to be honest, I did not understand that. About Males etc. and my attempts were rejected.

But I found another link which has fixed it
=Field(FactOwner(%FACT%,1,MALES_FIRST),'INDI.NAME:SURNAME_FIRST')

This appears to produce both males and females?
And at the same time that added column sorts the Record owner column alongside, regardless of gender.

Re: Tutorial on Queries

Posted: 11 May 2019 17:03
by tatewise
That expression is exactly what my link provides.
Yes, it lists both males and females when the Fact owner is an Individual record.

BUT if the Fact is such as Marriage then the owner is a Family record and only the husband is listed.
To list the wife needs =Field(FactOwner(%FACT%,1,FEMALES_FIRST),'INDI.NAME:SURNAME_FIRST')

Remember that when you sort on ANY column it actually sorts the whole ROW, the same as sorting in a spreadsheet.
So yes ALL the columns will move in synch with the sorted column.

Think about it. If sorting one column only sorted that column and left all the others alone, that would be a real mess!

Re: Tutorial on Queries

Posted: 12 May 2019 17:11
by E Wilcock
Yes of course. Thank you for explaining about the gender thing. I am a bit slow.
And of course too about the sorting. Just that I had not expected so have a sorted, clickable list of names along side the one which is not clickable. A welcome by-product.

Re: Tutorial on Queries

Posted: 12 May 2019 17:59
by tatewise
Not sure what you mean by "along side the one which is not clickable".
It is clickable and sortable, but simply that it sorts by Forename.

Re: Tutorial on Queries

Posted: 13 May 2019 09:40
by E Wilcock
As always, Mike is correct. My choice of words not sufficiently precise. But from user point of view, one finds that the clickable list is now (indirectly) sorted by surname.

Re: Tutorial on Queries

Posted: 13 May 2019 10:20
by tatewise
I think your wording is still a little misleading.
In any Query (and other lists) ALL the column headers are clickable to sort the rows into that column order.
So if you click on new Owner column we've been discussing the rows sort into Surname order.
Click on original Record Owner column and the rows sort into Forename order, or more strictly cell text alphanumeric order.
Click on the Rec Id column and the rows sort into Record Id order.
Click on the Label column nnd the rows are sorted into Fact Label alphabetical order.
Click on the Date column and the rows are sorted into date order.
etc, etc...

Re: Tutorial on Queries

Posted: 31 Oct 2021 13:06
by quarlton
Hi

I've been trying to adapt the INDI.~FATH>CENS[year=" . Year(%FACT.DATE%) . "].PLAC" example to use with a parameter.

In this example: %INDI.CENS[year=1851]% the 1851 would be a parameter

What I came up with was

%INDI.CENS[year= . "Year(["Param"]) . "]"%
%INDI.CENS[year= . "Year(["Param"]) . "]%"

Both of which fail to work

Re: Tutorial on Queries

Posted: 31 Oct 2021 13:28
by tatewise
Yes, it is a bit tricky and needs the =GetField( ) function.
See https://www.family-historian.co.uk/help ... field.html
The help for that function just happens to give as an example exactly what you need:

=GetField(%INDI%,"%INDI.CENS[year=" . ["Year"] . "]%")

Re: Tutorial on Queries

Posted: 31 Oct 2021 15:31
by quarlton
Many thanks Mike, it worked perfectly.