* Conditional Expressions in Queries

Questions regarding use of any Version of Family Historian. Please ensure you have set your Version of Family Historian in your Profile
Post Reply
avatar
quarlton
Diamond
Posts: 93
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Conditional Expressions in Queries

Post by quarlton » 12 Oct 2021 14:08

Is it possible to incorporate a Parameter into a conditional expression?

e.g.
I have a Parameter called 'EnterYear'
The value entered in 1920
What I want to do is do a conditional expression that displays different values depending on the Parameter value.
e.g.
=TextIf(["EnterYear"]=1920,"Success", "Fail")

FH won't accept that.
So I thought that I might need to convert the value to a number for it to evaluate properly.

I tested the conversion as below:
=Number(["EnterYear"])
The expression evaluates correctly and displays the value 1920 in the appropriate column.

However, incorporating into the conditional expression wasn't acceptable.
=TextIf(Number(["EnterYear"])=1920,"Success", "Fail")


So it would seem that the Parameter is acceptable in some cases, but not others.

I have had a look through FH Help and Mike Tate's posting in the KB 'Understanding Expressions' but couldn't find a solution.

Can anyone confirm that either it is not possible, or suggest a solution.

Many thanks
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs

User avatar
tatewise
Megastar
Posts: 22521
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Conditional Expressions in Queries

Post by tatewise » 12 Oct 2021 14:25

The Column Expression =TextIf(Number(["EnterYear"]) = 1920,"Success","Fail") works fine for me.
That is identical to your 2nd attempt posted below, so I cannot explain why it does not work for you.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
quarlton
Diamond
Posts: 93
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Conditional Expressions in Queries

Post by quarlton » 12 Oct 2021 14:33

Thanks Mike

I've just tried it for the umpteenth time and it worked!

No idea what went wrong before.

As usual many thanks for your input.

Dave
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs

avatar
quarlton
Diamond
Posts: 93
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Conditional Expressions in Queries

Post by quarlton » 12 Oct 2021 16:00

Having got my columns working the way I want, what I would like to do is something similar or rows, but I have a feeling that this is going to be a definet NoNo.

What I would like is to have two filters that use 'and'

Exclude Unless %INDI.BIRT[1].DATE% is null and Parameter = 1900
Exclude Unless %INDI.BIRT[1].DATE% is null and Parameter = 1945

Many thanks

Dave
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs

User avatar
tatewise
Megastar
Posts: 22521
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Conditional Expressions in Queries

Post by tatewise » 12 Oct 2021 16:09

That is a definite yes yes:

Exclude unless
=IsTrue( NullDate(%INDI.BIRT[1].DATE%) and Number(["Parameter"]) = 1900)
is true
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
quarlton
Diamond
Posts: 93
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Conditional Expressions in Queries

Post by quarlton » 12 Oct 2021 16:41

Mike you are brilliant😄
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs

Post Reply