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

Report should sort on price.

Status
Not open for further replies.

HaraldBuesching

Programmer
Sep 12, 2001
25
0
0
BE
We use 8.5..
I have a report with several groups.
The datasource is money and amount (and some other fields).
Now I want to sort each group on price. (TopN Expert doesn't work, because price = money/amount)

How do I do this?

Is there furthermore a way, that can I use a parameter to decide between sorting on money, amount or price?
 
hi,

Create a string parameter to select between you options money/amount/price.

Create two formulae...

{@price}
money/amount

{@order}
evaluateafter({@price};
local numbervar v;
if {?param} = "money" then v := {money}
else if {?param} = "amount" then v := {amount}
else v := {@price};
v

Then insert {@order} as a group. You will probably want to suppress the group header and footer.

This will then sort the report on any of these values based on the parameter supplied. {@price} can be displayed in yur details as necessary


Hth,
Geoff
 
Hi

My approach would be slightly different

1. I would create a parameter called "ReportSorting"
{?ReportSorting}

The instructions in the parameter would be to:
"Type 'A' for amount, 'M' for money or 'P' for price

Set the default to whatever value you want eg: price

2. I would create a formula called "Group - ReportSort"
{@Group - ReportSort}

**************** Start of formula****************

if uppercase({?ReportSorting}) = "M" then
{table.money}
else if uppercase({?ReportSorting}) = "A" then
{table.amount}
//this will be the default in case an invalid value
// for {?ReportSorting} is entered.
else
(if {table.money} = 0 then
0
else
{table.money}/{table.amount};);

**************** end of formula****************

3. create your report...then add one final group based on
{@Group - ReportSort} and sort this group ascending or
descending as you want. Suppress the header and footer

This should do the trick
Jim

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top