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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Group Sort Order

Status
Not open for further replies.

excalibur78

IS-IT--Management
Jan 3, 2001
66
US
Not sure if this can be done but here's what I'm trying to do. I need to have 3 groups all with data but need a way to change the sort order of them dynamically and suppress any group no wanted at run-time. 3 groups are products, sales people, and customers. Thanks for ay help you can provide.
 
[ol][li]Create three string parameter called {?Group1}, {?Group2} and {?Group3) with the following defaults:[ul][li]Products[/li][li]Salesperson[/li][li]Customer[/li][li]None (only in {?Group2} and {?Group3})[/li][/ul][/li][li]Create 3 separate formulas, 1 for each group[/li][ul][li]//@Group1
If
{?Group1} = "Products"
Then
{table.products}
Else If
{?Group1} = "Salesperson"
Then
{table.salesperson}
Else If
{?Group1} = "Customer"
Then
{table.customer}[/li][li]//@Group2/@Group3 are the same
//just change the formula name

If
{?Group2} = "Products"
Then
{table.products}
Else If
{?Group2} = "Salesperson"
Then
{table.salesperson}
Else If
{?Group2} = "Customer"
Then
{table.customer}
Else If
{?Group2} = "None"
Then
""[/li][/ul][/li][li]Insert three groups based on the {@Group1}, {@Group2} and {@Group3} formulas[/li][/ol]Alternately, you could create one parameter with a list of every available combination. Example:[ul][li]Products/Salesperson/Customer[/li][li]Products/Customer/Salesperson[/li][li]etc...[/li][/ul]but this makes your group formulas unecessarily complex because you'd have to account for every combination in your formulas. If you're using CR8+ you could do this with a case statement, which would reduce the verbiage.
 
I got that far. Trying to figure out how to use the items in the exact order they are selected in a multiple select parameter. Then use this to arrange the groups on the report. The groups use the above code pretty much. So if the user selects products and customer the top group is products and next is customer. Then if they refresh it and enter new values this time the do customer then sales person and the top group is customer and next is sales person. Looking to control the tree view dynaically =) Any help would be great.
 
If it's always just 3 choices froma single parameter, then use 3 formulas:

group1 will =

{?My Groups}[1]

group2 will =

{?My Groups}[2]

group1 will =

{?My Groups}[3]

As an example of extracting the choices in a multi parameter, this loop will extract the choices from a multi parameter into a comma delimited string (I use this to demonstrate to users the choices they made in the report):

WhilePrintingRecords;
Local Stringvar Array InputNum := {?My Parameter};
Local StringVar str := "";
Local NumberVar strLen := Count (InputNum);
Local NumberVar i;



For i := 1 to strLen
Step + 1
Do (
if i <> strlen then
str := str + InputNum + &quot;, &quot;
else
str := str + InputNum )
;

-k kai@informeddatadecisions.com
 
I have never considered multi-input parameters but that might work really well.

you would only need one group that way

I would create a grouping formula

@Group
numberVar icount;
stringVar Result := Join({?ParamSortOrder},&quot;/&quot;);

if Result = &quot;Products/Salesperson/Customer&quot; then
{table.products} + &quot;/&quot; + {table.Salesperson} + &quot;/&quot; +
{table.Customer}
else if Result = &quot;Products/Customer/Salesperson&quot; then
{table.products} + &quot;/&quot; + {table.Customer} + &quot;/&quot; +
{table.Salesperson}
else if Result = &quot;Salesperson/Products/Customer&quot; then
{table.Salesperson} + &quot;/&quot; + {table.products} + &quot;/&quot; +
{table.Customer}
else if Result = &quot;Salesperson/Customer/Products&quot; then
{table.Salesperson} + &quot;/&quot; + {table.Customer} + &quot;/&quot; +
{table.products}
else if Result = &quot;Customer/Salesperson/Products&quot; then
{table.Customer} + &quot;/&quot; + {table.Salesperson} + &quot;/&quot; +
{table.products}
else if Result = &quot;Customer/Products/Salesperson&quot; then
{table.Customer} + &quot;/&quot; + {table.products} + &quot;/&quot; +
{table.Salesperson}
//always have a catch-all default, incase of bad input
else
{table.products} + &quot;/&quot; + {table.Salesperson} + &quot;/&quot; +
{table.Customer} ;

I might make your inputs for {?ParamSortOrder}simpler to
&quot;P&quot; for Products, &quot;S&quot; for Salesman and &quot;C&quot; for Customer

put that in yur parameter description

then your comparison could be

if upperCase(Result) = &quot;P/S/C&quot; then

this would make user input simpler and account for mixed case.

I have never tried this but think it will work...


Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top