Hot Topic (More than 10 Replies) Help with totals, subtotals, and reports please (Read 1945 times)
Kerinst
Member
*
Offline


If you can't do it right
lemme do it wrong for
you

Posts: 32
Location: North Dakota
Joined: Jun 3rd, 2004
Help with totals, subtotals, and reports please
Aug 5th, 2004 at 6:06pm
Print Post Print Post  
I'm working on what I thought would be an easy database to show how much we sell of a particular item, sum up how much we made on that item, then add that total with everything else we sold and get a profit figure... should be simple except I'm completely lost how to attempt such a feat...

We sell about 35 items, we charge differently based on who is picking them up, which makes it difficult to just toss it into an inventory program and get an accurate outcome... so I built a small program that has no calculations, it just shows what they purchased, how much of it and what it cost... if I build a report it will sort according to this description, but is there anyway to get it to add up every item of that same description??

I can get a complete total just using sum at the footer of my report
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Help with totals, subtotals, and reports pleas
Reply #1 - Aug 5th, 2004 at 6:26pm
Print Post Print Post  
Click on the Group Body section label. A Break dialog will open.  Choose your Description element as the Break Element.

Put a Sum element in the Group Footer.

This will cause the report to break and print a sum each time the Description changes.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Kerinst
Member
*
Offline


If you can't do it right
lemme do it wrong for
you

Posts: 32
Location: North Dakota
Joined: Jun 3rd, 2004
Re: Help with totals, subtotals, and reports pleas
Reply #2 - Aug 5th, 2004 at 6:56pm
Print Post Print Post  
OK I made it that far after finally finding the section I was mission from the book... now I get a report where the same item comes up 5 times and it calculates the total paid for that item... how can I get it to just show the item 1 time and the totals for that item??

example

we sell rock so right now it says

rock 45 $370.00
rock 48 $390.00
rock 55 $415.00
                           $1175.00

can I make a report where all it will say is

rock $1175.00
gravel $1400.00

thanks
asking for miracles I know   Grin
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Help with totals, subtotals, and reports pleas
Reply #3 - Aug 5th, 2004 at 7:18pm
Print Post Print Post  
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Kerinst
Member
*
Offline


If you can't do it right
lemme do it wrong for
you

Posts: 32
Location: North Dakota
Joined: Jun 3rd, 2004
Re: Help with totals, subtotals, and reports pleas
Reply #4 - Aug 6th, 2004 at 1:56pm
Print Post Print Post  
Thanks for the help there Hammer, I'm still lost but am trying   Smiley

is there a Sesame for idiots that I can get somewhere, I've never been a programmer until this was all handed to me and somebody said build it   Tongue
  
Back to top
 
IP Logged
 
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Help with totals, subtotals, and reports pleas
Reply #5 - Aug 6th, 2004 at 2:16pm
Print Post Print Post  
I just ordered inside sesame and downloaded all the prior issues, From what I can tell, anyone building a fairly complicated application its a must.    Grin
  
Back to top
 
IP Logged
 
Kerinst
Member
*
Offline


If you can't do it right
lemme do it wrong for
you

Posts: 32
Location: North Dakota
Joined: Jun 3rd, 2004
Re: Help with totals, subtotals, and reports pleas
Reply #6 - Aug 6th, 2004 at 2:53pm
Print Post Print Post  
Yep I got them too Proudpuppy but they don't help with using a simple mind to create a complex program   Grin

I am going to reread the programming guide this weekend and see if Monday I can't make this thing work the way I want it to   Roll Eyes
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Help with totals, subtotals, and reports pleas
Reply #7 - Aug 6th, 2004 at 3:52pm
Print Post Print Post  
Kerinst,

There is a simpler way to do this that requires less programming and only uses a single view. I tested this using the sample Customers database, using "City" where you would be using "Description", and using "Numerical" where I think you have Quantity. But I have changed the names below to be closer match to your application:

1. Build a report
2. Add an "unbound" value element to the "Group Header". Call it "eReset".
3. Add a value element to the "Group Body". Bind it to "Description". Call it eDescription. Make it invisible.
4. Add a value element to the "Group Body". Bind it to "Quantity". Call it "eQuantity". Make it invisibile.
5. Add an "unbound" value element to the "Group Footer". Call it "eLabel".
6. Add an "unbound" value element to the "Group Footer". Call it "eTotal".
7. Add the following programming:
in Global Code:
Code
Select All
var vTotal as double
var vOldNumber as double
var vOldDescription as string
vTotal = 0
vOldNumber = 0
 


In eReset On Print
Code
Select All
vTotal = 0
vOldDescription = vDescription
 


In vDescription On Print
Code
Select All
vTotal = vTotal + vOldNumber
vOldNumber = eQuantity
 


in eLabel On Print
Code
Select All
eLabel = vOldDescription
eTotal = vTotal
vOldDescription = eDescription
 


8. By right clicking on the title above the "Group Body" column, set the "Break Element" to eDescription with a break code of zero.
9. When running the report, you *must* sort by "Description" - so it is a good idead to attach the sort spec to the report.

This approach will run through your result set (that has already been sorted by "Description"), as it wants to print each and every description, it totals up the "Quntity" - the description does not print because it is invisible. But when when the description changes a break happens, allowing the code to print the description as a label and print the running total. It then resets the running total for the next "group".

Part of the trick to learning how to program is to pretend that you are doing the task you are asking the program to do. In this case, pretend you are the report writer. You get handed a card on which is written the fields in each of your records. They get handed to you in sorted order. You have pen and paper so you can take notes and keep running totals (setting and incrementing variables), and after you have been handed each of the cards you write down your results (the report itself) labeling your totals as necessary.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Help with totals, subtotals, and reports pleas
Reply #8 - Aug 6th, 2004 at 4:06pm
Print Post Print Post  
Ray - the author of the original example, has pointed out that the technique above will produce "empty table" rows in the HTML output. These are not readily visible if you do not have many records per description. But will become more visible as the number of records per description increase.

In that light, take the example above as a good example (simplified) so that you can get a handle on the concepts involved in Ray's less trivial example.

....And, come to think of it, I just fixed the report writer so it no longer creates a row for otherwise completely invisible entries. It will be in the next release.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Kerinst
Member
*
Offline


If you can't do it right
lemme do it wrong for
you

Posts: 32
Location: North Dakota
Joined: Jun 3rd, 2004
Re: Help with totals, subtotals, and reports pleas
Reply #9 - Aug 6th, 2004 at 4:57pm
Print Post Print Post  
THANKS COW   Grin

the only problem there is it keeps giving me a 0 for the last item listed... but I found if I add that item twice it comes out allright... now I can take my time and program it properly and they will still be happy with it for now  Cheesy
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Help with totals, subtotals, and reports pleas
Reply #10 - Aug 6th, 2004 at 5:39pm
Print Post Print Post  
Yeah, sorry. I rattled it off very quickly. I hope it has helped illustrate the technique, even if its a little rough around the edges.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged