Page 1 of 1

Conditional Expressions in Queries

Posted: 12 Oct 2021 14:08
by quarlton
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

Re: Conditional Expressions in Queries

Posted: 12 Oct 2021 14:25
by tatewise
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.

Re: Conditional Expressions in Queries

Posted: 12 Oct 2021 14:33
by quarlton
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

Re: Conditional Expressions in Queries

Posted: 12 Oct 2021 16:00
by quarlton
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

Re: Conditional Expressions in Queries

Posted: 12 Oct 2021 16:09
by tatewise
That is a definite yes yes:

Exclude unless
=IsTrue( NullDate(%INDI.BIRT[1].DATE%) and Number(["Parameter"]) = 1900)
is true

Re: Conditional Expressions in Queries

Posted: 12 Oct 2021 16:41
by quarlton
Mike you are brilliant😄