Robert Schumann
asked on
MS Report - Sum Function
Hi - I'm trying to sum the amount in a report that is Grouped by Orders, the group will show Capital and Expense orders. Trying to show separate total amounts for Capital and Expense orders in the Report Header.
I'm using a text field with =Sum((SELECT [Amount] WHERE [OrderType] = "Capital")) but getting an #Error
Thanks
Bob
I'm using a text field with =Sum((SELECT [Amount] WHERE [OrderType] = "Capital")) but getting an #Error
Thanks
Bob
ASKER
Your right, needed more criteria.
Trying this but it's giving me the total amount for the entire table. Not filtering just the Asset items by Expense.
=DSum("Amount","PurchaseOr ders",[Ass et]="99992 427" And [OrderType]="Expense")
Trying this but it's giving me the total amount for the entire table. Not filtering just the Asset items by Expense.
=DSum("Amount","PurchaseOr
The statement is not delimited correctly. There are three arguments, the field you want to sum, the table or query that is the domaiin, and the criteria.
=DSum("Amount","PurchaseOr ders","[As set]='9999 2427' And [OrderType]='Expense'")
Notice how the criteris is all encapsulated into a string. Getting the syntax correct when you need embedded quotes can be tricky.
Hard-coding the asset is probably the wrong approach.
=DSum("Amount","PurchaseOr
Notice how the criteris is all encapsulated into a string. Getting the syntax correct when you need embedded quotes can be tricky.
Hard-coding the asset is probably the wrong approach.
no points please:
The syntax for the DSUM() would look something like:
=DSum("Amount","PurchaseOr ders","[As set]=99992 427 And [OrderType]='Expense'")
of, if [Asset] is a string:
=DSum("Amount","PurchaseOr ders","[As set]='9999 2427' And [OrderType]='Expense'")
Dale
The syntax for the DSUM() would look something like:
=DSum("Amount","PurchaseOr
of, if [Asset] is a string:
=DSum("Amount","PurchaseOr
Dale
ASKER
Pat and Dale
Your both right. It does show the correct total for the Order Type of Capital or Expense. But it's putting the total in both Groups.
If I try this I get an #Error
=DSum("Amount","PurchaseOr ders","[As set]='9999 2427' And [OrderType]='Expense' And ‘[OrderType]=’Capital’")
Your both right. It does show the correct total for the Order Type of Capital or Expense. But it's putting the total in both Groups.
If I try this I get an #Error
=DSum("Amount","PurchaseOr
ASKER
Correction - there are two groups, Capital and Expense. It's putting the same total in both groups. In this it's only identifying Expense, it should only put the amount in the Expense group. However it's putting the correct amount in both the Capital and Expense group. I still need to add the group Capital to the equation.
=DSum("Amount","PurchaseOr ders","[As set]='9999 2427' And [OrderType]='Expense'")
=DSum("Amount","PurchaseOr
you have an extra ' before the [OrderType] field, try:
=DSum("Amount","PurchaseOr ders","[As set]='9999 2427' And [OrderType]='Expense' And [OrderType]=’Capital’")
=DSum("Amount","PurchaseOr
ASKER
oops, just saw that.
Getting an #Error. Is it possible what I'm trying isn't possible? Would there be a better way?
Getting an #Error. Is it possible what I'm trying isn't possible? Would there be a better way?
ASKER
Guys,
I did a work around.
I created another text field for Capital. I needed these to do calculations in the report header. I'll reference these two text boxes in the Header and simply hide the fields within the groups.
Thank you both.
I did a work around.
I created another text field for Capital. I needed these to do calculations in the report header. I'll reference these two text boxes in the Header and simply hide the fields within the groups.
Thank you both.
You do realize that the Report header only ever prints ONCE at the beginning of the report.
Did you try to use sum over Group/All. Split Expense and Capital in detail section.
Setting the value in header comes next.
Setting the value in header comes next.
Here is a way using Sum Over Group/All
Almost identical report inserted as a subreport,, Visible=no, just to make the total available to the main report..
Run b_report_total_per_group_i n_header report.
b_report_total_per_group_i n_header2 is the subreport.
report-per-group-total-in-header.accdb
Almost identical report inserted as a subreport,, Visible=no, just to make the total available to the main report..
Run b_report_total_per_group_i
b_report_total_per_group_i
report-per-group-total-in-header.accdb
ASKER
Big thank you to all. hnasr - wouldn't have gotten that! Pat and Dale what you gave me kind of worked. Adding and referencing other text fields did the trick.
Thank you all..
Thank you all..
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
However, I think you probably need more criteria than just "=capital".