Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I group through a selection Formula

Status
Not open for further replies.

jspur2003

MIS
Oct 11, 2004
59
US
Ok Im using Crystal 8.5 and below is my selection

Code:
IF {?Include Special Charges}="NO"or
    {?Include Special Charges}="no"then
not ({LOT.ILT_ITEM} in ["1","2","3","4","5","C","C1","C2","C3","C4",
"C5", "C6","F","f 12 DSE","f 13 DMS","f 14 DMW","f10","f2","f3","f4","f5","p"]) and
(
{LOT.ILT_CUST#} in {?Customer From} to {?Customer To} and
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To}) or 
{?Customer Class} ={LOT.RCM_CLASS} and
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To}) or
{?Customer Name} = {LOT.RCM_NAME} and
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To}) 
)

or


IF {?Include Special Charges}="NO"or
    {?Include Special Charges}="no"then
not ({LOT.ILT_ITEM} in ["1","2","3","4","5","C","C1","C2","C3","C4",
"C5", "C6","F","f 12 DSE","f 13 DMS","f 14 DMW","f10","f2","f3","f4","f5","p"]) and
(
{LOT.ILT_CUST#} in {?Customer From} to {?Customer To} and
{@End Date} in DateTime ({?Second Date Range From}) to DateTime ({?Second Date Range To}) or
{?Customer Class} ={LOT.RCM_CLASS} and
{@End Date} in DateTime ({?Second Date Range From}) to DateTime ({?Second Date Range To}) or
{?Customer Name} = {LOT.RCM_NAME} and
{@End Date} in DateTime ({?Second Date Range From}) to DateTime ({?Second Date Range To})
)
else 

IF {?Include Special Charges}= "YES" then
{LOT.ILT_CUST#} in {?Customer From} to {?Customer To} and
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To}) or 
{?Customer Class} ={LOT.RCM_CLASS} and
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To}) or
{?Customer Name} = {LOT.RCM_NAME} and
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To})
or

{LOT.ILT_CUST#} in {?Customer From} to {?Customer To} and
{@End Date} in DateTime ({?Second Date Range From}) to DateTime ({?Second Date Range To}) or
{?Customer Class} ={LOT.RCM_CLASS} and
{@End Date} in DateTime ({?Second Date Range From}) to DateTime ({?Second Date Range To}) or
{?Customer Name} = {LOT.RCM_NAME} and
{@End Date} in DateTime ({?Second Date Range From}) to DateTime ({?Second Date Range To})
What i want to accomplish is when the they choose customer
Code:
{?Customer Class} ={LOT.RCM_CLASS}
class is will make a group to group the records it pulls by customer number If you need me to give you some more info let me know so instead of listing All Items for that customer class it will group the items by customer number
 
Your post is somewhat confusing as you title it with "How can I group through a selection Formula", which tends to make people think about grouping data, although the post seems to mean that you want to distinctly separate the record selection formula.

Groups have nothing to do with the record selection formula.

I did a cursory revamp of the record selection formula in hopes of increasing readability (and did it suddenly become hip to forego meaningful punctuation in posts, it makes it mroe difficult to understand? Many people are doing it lately, I hope that every one of their manuals come this way in the future ;) ).

Using parentheticals in the record selection formula will greatly improve the odds of passing SQL to the database, and it helps to clearly identify to Crystal what you are intending.

I doubt that I got it exactly right, but check out:

(
IF {?Include Special Charges}="NO"or
{?Include Special Charges}="no" then
(
not ({LOT.ILT_ITEM} in ["1","2","3","4","5","C","C1","C2","C3","C4",
"C5", "C6","F","f 12 DSE","f 13 DMS","f 14 DMW","f10","f2","f3","f4","f5","p"])
)

and

(
{LOT.ILT_CUST#} in {?Customer From} to {?Customer To}
)

and

(
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To})
or
{?Customer Class} ={LOT.RCM_CLASS}
)

and

(
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To})
or
{?Customer Name} = {LOT.RCM_NAME}
)

and

(
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To})
)
)

OR

(
IF {?Include Special Charges}="NO"
or
{?Include Special Charges}="no" then
(
not ({LOT.ILT_ITEM} in ["1","2","3","4","5","C","C1","C2","C3","C4",
"C5", "C6","F","f 12 DSE","f 13 DMS","f 14 DMW","f10","f2","f3","f4","f5","p"])
)

and

(
{LOT.ILT_CUST#} in {?Customer From} to {?Customer To}
)

and

(
{@End Date} in DateTime ({?Second Date Range From}) to DateTime ({?Second Date Range To})
or
{?Customer Class} ={LOT.RCM_CLASS}
)

and

(
{@End Date} in DateTime ({?Second Date Range From}) to DateTime ({?Second Date Range To})
or
{?Customer Name} = {LOT.RCM_NAME}
)

and

(
{@End Date} in DateTime ({?Second Date Range From}) to DateTime ({?Second Date Range To})
)

else
IF {?Include Special Charges}= "YES" then
(
{LOT.ILT_CUST#} in {?Customer From} to {?Customer To}
)

and

(
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To})
or
{?Customer Class} ={LOT.RCM_CLASS}
)

and

(
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To})
or
{?Customer Name} = {LOT.RCM_NAME}
)

and

(
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To})
or
{LOT.ILT_CUST#} in {?Customer From} to {?Customer To}
)

and

(
{@End Date} in DateTime ({?Second Date Range From}) to DateTime ({?Second Date Range To})
or
{?Customer Class} ={LOT.RCM_CLASS}
)

and

(
{@End Date} in DateTime ({?Second Date Range From}) to DateTime ({?Second Date Range To})
or
{?Customer Name} = {LOT.RCM_NAME}
)

and

(
{@End Date} in DateTime ({?Second Date Range From}) to DateTime ({?Second Date Range To})
)
)

This whole thing could be reduced significantly, and th first section seems to be identical to the second, and each has recurring section that could just be outside of the IF.

This seems a part of everything, so just place it first in the record selection without an IF and only IF those areas that require it:

(
{LOT.ILT_CUST#} in {?Customer From} to {?Customer To}
)

and

(
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To})
or
{?Customer Class} ={LOT.RCM_CLASS}
)

and

(
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To})
or
{?Customer Name} = {LOT.RCM_NAME}
)
and

(
{@Begin Date} in DateTime ({?First Date Range From}) to DateTime ({?First Date Range To})
)

-k
 
Thanks for the help... Sorry bout my code im not a programmer i try to stay away from programming as much as possible but within a small company i have to code sometimes...
 
Nae worries, your code is pretty good, you're doing fine.

I'm still unclear what you wanted to do though if it's other than what I did.

-k
 
I used your code to help clear mine up some but the way i solved my problem was to change the format all together
so i created a new report from scratch and start off by grouping by CUST# and by ITEM..
What I was trying to do was group by CUST# and then By ITEM only if they choose a certain Class in the paramater..so it would display the customer number then list the Items for that customer
EX
Before
Code:
ITEM   QTYlastyr  QTYthisyr
1001     15           20
1005     25           35
1015     15           30
1227     225          220
1001     20           40
1015     63           90
1519     25           45
1965     15           25
What i wanted to accomplish
Code:
ITEM   QTYlastyr  QTYthisyr
Customer# 1005
1001     15           20
1005     25           35
1015     15           30
1227     225          220

Customer# 2005
1001     20           40
1015     63           90
1519     25           45
1965     15           25
I know they dont equal up i just threw it together as a quick example
 
Group by customer?

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Try creating a formula called {@Grp1Formula} like so:

If {?ClassParm} = "ACertainValue" then
Customer-Id else " "

Make this formula group 1 and suppress it if
{?ClassParm} <> "ACertainValue"

Group 2 should be Item.

MrBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top