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

Sum a variable in details

Status
Not open for further replies.

ij76

Technical User
Mar 15, 2005
25
CA
In CR v9

I have a report where I list expenses. I have groups which consist of Employee Name (gr 1) and date of expenses (gr 2). In the details I have the expense type, the expense description and a formula to apply a currency rate to the expense amount.

The way I need the details to diplay is, if the expense type is = meals then sum up the total amount of meals for that one day. For all other expense type, just list for each entry.

I know this will take variables, which I took a stab at and I was ablt to get the numbers, but am unsure how to display them the way I need them to.

I created the following varibles formulas:

Reset:
whileprintingrecords;
currencyvar meals :=0;

Declared:
whileprintingrecords;
if {ExpenseType.Description}="Meals" then currencyvar meals := meals+{@USD} else {@USD};

Display:
whileprintingrecords;
currencyvar meals;

With these, I am getting the accumulative summary for all expense types "meals" and the individual amounts for all other types in the details section. In the group footer 2 section, I have the total of all expense type "meals" showing.

How can I show a list of all expense types and their individual amounts, except for the "meals" types where I would need to show one line with just the total for that day.
 
Do a suppress of the details where type = meals, and then modify your details formula to:

whileprintingrecords;
currencyvar meals;
if {ExpenseType.Descrtion}="Meals" then
currencyvar meals := meals+{@USD}

Of course this assumes a good deal since you didn't bother to post the key ingredient, what's in the @USD formula...

I think that it should read something like

whileprintingrecords;
currencyvar meals;
if {ExpenseType.Descrtion}="Meals" then
currencyvar meals := meals+{Expensetype.amount}

Now place your Display formula in the date grouping footer.

So all of those that are not meals will display in the details, and only the sum of meals will display at the end of the details.

-k
 
I didn't think the @USD formula was necessary, but it is:

if {ExpensesCharged_Fact.CurrencyCode}="USD" then ({ExpensesCharged_Fact.UnitPrice}*{ExpensesCharged_Fact.Quantity})*1.00 else {ExpensesCharged_Fact.UnitPrice}*{ExpensesCharged_Fact.Quantity}*{@Exchange rate}

I thought about doing what you mention (suppressing "meals" and having that show at the bottom). My problem with that is that I get blank lines for where the "meals" used to be in the details. Unless you know of a way I can get rid of the blank lines, that would work.
 
Cancel the last post...I figured out how to suppress in the details section format. I didn't know about that oen before.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top