Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Use Formula field in select record Post Reply Post New Topic
Author Message
trac
Newbie
Newbie


Joined: 25 Apr 2012
Online Status: Offline
Posts: 13
Quote trac Replybullet Topic: Use Formula field in select record
     Posted: 08 Dec 2013 at 3:24am
created a formula field called Fieldname which I wish to filter data through select expert. is this the right way? or do I need to create a parameter?
In Formula editor this is the formula used:
If table1.column1 in [value1, value2,value3, value4] then column1
else if isnull table1.column1 then table2.column2.

In short if table1.column1 is in the 4 values pick that value else if table1.column1 has null values pick up value from table2.column2. Table1 and table2 are inner joined. This value of Formula field is just for filtering data and is not required to display in the report.
I am NOT getting the desired result. Any suggestions appreciated.




 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 09 Dec 2013 at 5:18am
a filter formula returns true or false...true-include the row in the report, false-omit the row.

your formula seems to be more about display. to make it more of filter:
isnull({table1.column1}) or {table1.column1} in [value1,value2, value3, value4]

this will return true or false.

HTH
IP IP Logged
trac
Newbie
Newbie


Joined: 25 Apr 2012
Online Status: Offline
Posts: 13
Quote trac Replybullet Posted: 09 Dec 2013 at 5:02pm
Thanks. But It didn't help. Is there any other way round?

I am joining 2 tables which has 1 column called state. I wish to check if table1.state IN ["value1, value2] then pick table1.state else if table1.column1 has null values pick up value from table2.state. Any suggestions appreciated.
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 09 Dec 2013 at 10:24pm
Hi

Your formula is more on defining condition, so create same formula under formula fields (not in record selection formula) like :

@Formula
If table1.column1 in [value1, value2,value3, value4] then column1
else if isnull table1.column1 then table2.column2

Now go in record selection formula and give below condition :

{@formula} = True

This will pickup only required record set.
Thanks,
Sastry
IP IP Logged
trac
Newbie
Newbie


Joined: 25 Apr 2012
Online Status: Offline
Posts: 13
Quote trac Replybullet Posted: 10 Dec 2013 at 2:18am
Thanks Sastry. Yes I did create a formula field and in record selection did select formula field = True, then I get zero results.
IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 10 Dec 2013 at 9:20am
i think you need
formula1
if isnull(table1.column1) then table2.column2 else
table1.column1

select expert
formula1 in [value1, value2,value3, value4]
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum