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
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.
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
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
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.
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})
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?!
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