Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Help in Creating Selection Formula Post Reply Post New Topic
Author Message
linverno
Newbie
Newbie


Joined: 15 Sep 2009
Location: Egypt
Online Status: Offline
Posts: 4
Quote linverno Replybullet Topic: Help in Creating Selection Formula
     Posted: 15 Sep 2009 at 1:28am
I have a report which contain two parameters one of them is a range parameter, the other is distinct.

this is my selection formula (record selection)

if HasLowerBound({?InvDate}) THEN
    {command.InvDate} >= Minimum({?InvDate});
if HasUpperBound({?InvDate}) THEN
    {command.InvDate} <= Maximum({?InvDate});

{command.InvId} = {?InvId};


if we rewrite this formula to be in T-SQL form
and write the values directly it will be like this:

WHERE    invDate >= "01/01/2008"
OR
invDate <= "12/31/2008"
OR InvId = 251

I didn't need it to be OR I need it to be AND




Edited by linverno - 15 Sep 2009 at 2:33am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 15 Sep 2009 at 6:30am
it would seem you want something like:
if HasLowerBound({?InvDate}) THEN (
    {command.InvDate} >= Minimum({?InvDate});
    {command.InvDate} <= Maximum({?InvDate});
)
else
 //I'm just guessing, 
    {command.InvId} = {?InvId};
IP IP Logged
linverno
Newbie
Newbie


Joined: 15 Sep 2009
Location: Egypt
Online Status: Offline
Posts: 4
Quote linverno Replybullet Posted: 16 Sep 2009 at 1:14am
No,
actually, I need something like this:

{command.InvId} = {?InvId};

if HasLowerBound({?InvDate}) THEN (
   AND {command.InvDate} >= Minimum({?InvDate});
   AND {command.InvDate} <= Maximum({?InvDate});
)

I read couple of books about crystal report, the chapters that talking about formula it's just concatenate some strings With some values. or assign values to some variables.
No book talking about what I want.
IP IP Logged
Ibzy
Newbie
Newbie
Avatar

Joined: 16 Sep 2009
Location: United Kingdom
Online Status: Offline
Posts: 6
Quote Ibzy Replybullet Posted: 16 Sep 2009 at 4:17am
Hi Linverno,

I think that formula is very close, but just need to change a couple of things:

{command.InvId} = {?InvId};

if HasLowerBound({?InvDate}) THEN
   {command.InvDate} >= Minimum({?InvDate})
   ELSE {command.InvDate} <= Maximum({?InvDate})


Does that do what you need?
IP IP Logged
linverno
Newbie
Newbie


Joined: 15 Sep 2009
Location: Egypt
Online Status: Offline
Posts: 4
Quote linverno Replybullet Posted: 16 Sep 2009 at 5:47am
Hi lbzy,

what I want is

Field called InvId = value of InvId parameter

AND

Field called InvDate >= Lower value of InvDate Parameter

AND

Field called InvDate <= Upper value of InvDate Parameter


All what I want is AND


the formula:
{command.InvId} = {?InvId};
if HasLowerBound({?InvDate}) THEN
   {command.InvDate} >= Minimum({?InvDate})
if HasUpperBound({?InvDate}) THEN
   {command.InvDate} <= Maximum({?InvDate})

is working as:

Field called InvId = value of InvId parameter

OR

Field called InvDate >= Lower value of InvDate Parameter

OR

Field called InvDate <= Upper value of InvDate Parameter



IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 16 Sep 2009 at 6:09am
{command.InvId} = {?InvId} AND {command.InvDate} IN Minimum({?InvDate})  AND Maximum({?InvDate})
 
How about that.  You already know that the ?InvDate has an upper and lower bound, so why test it...especially when you test is leading to an ORing not and ANDing.
IP IP Logged
Ibzy
Newbie
Newbie
Avatar

Joined: 16 Sep 2009
Location: United Kingdom
Online Status: Offline
Posts: 6
Quote Ibzy Replybullet Posted: 16 Sep 2009 at 6:18am
I'm assuming {command.InvDate} is a range and you want the start and end of the range assigned that of {?InvDate}:

{command.InvId} = {?InvId};
if HasLowerBound({?InvDate}) THEN
   Minimum{command.InvDate} >= Minimum({?InvDate})
if HasUpperBound({?InvDate}) THEN
   Maximum{command.InvDate} <= Maximum({?InvDate})

IP IP Logged
linverno
Newbie
Newbie


Joined: 15 Sep 2009
Location: Egypt
Online Status: Offline
Posts: 4
Quote linverno Replybullet Posted: 18 Sep 2009 at 2:35pm
Ok guys

Why you don't read my words well!!!
if you read my first post you will find that:

this is my formula
if HasLowerBound({?InvDate}) THEN
    {command.InvDate} >= Minimum({?InvDate});
if HasUpperBound({?InvDate}) THEN
    {command.InvDate} <= Maximum({?InvDate});

{command.InvId} = {?InvId};


and the three conditions in this formula

not working as I want
they working like this:

condition 1 OR condition 2 OR condition 3
I need it to work like this:
condition 1 AND condition 2 AND condition 3

are you realize the difference?


If I don't have an If statement there will be no problem
I will write AND between conditions
the problem is I can't write the formula like this:
{command.InvId} = {?InvId};
if HasLowerBound({?InvDate}) THEN
    AND {command.InvDate} >= Minimum({?InvDate});
if HasUpperBound({?InvDate}) THEN
    AND {command.InvDate} <= Maximum({?InvDate});

Can any one help in this
Or the selection formula not a good choice?!



Edited by linverno - 18 Sep 2009 at 2:41pm
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