Normal Topic Column Report trouble (Read 1321 times)
Journey
Member
*
Offline


No personal text

Posts: 2
Joined: Jan 25th, 2004
Column Report trouble
Jan 25th, 2004 at 1:13am
Print Post Print Post  
I am trying to create a simple column Report from my Customer database. I want to count my customers by State. I'm looking for a Report that looks exactly like this, with the count directly to the right of the states:

State     Count
CA                                                     23
NY                                                                     7
NY                                                                  12      

I have a Layout element that contains the State values, but I'm having much trouble creating the Report. Anybody know how?
  
Back to top
 
IP Logged
 
TJCajun
Junior Member
**
Offline


"Laissez les bons temps
rouler"

Posts: 72
Location: Louisiana
Joined: Nov 25th, 2002
Re: Column Report trouble
Reply #1 - Jan 25th, 2004 at 3:06am
Print Post Print Post  
I've got something close.  It looks like this:
  (here in the Sesame Forum, the count values may not show up under the COUNT column, but they do in the report)

STATE   COUNT
AR 
AR 
AR 
                                                    3
STATE   COUNT
AZ 
AZ 
AZ 
AZ 
AZ 
AZ 
AZ 
AZ 
AZ 
AZ 
                                                      10



I can't figure out how to stop the STATE values from repeating, or to get a single STATE abbreviation and the COUNT to appear on the same line.

Here's column info that I set up in a report:

Under Group Header I have 2 Static Text entries:
  STATE
  COUNT
(These are the column headings)

Under Group Body I have a Value Box that is bound to State.  It shows as [LE1]

Under Group Footer I have entered a Spacer, which shows up as [LE2] and a Summary Calculation of Count which is bound to State.  It shows as [LE3]

Be sure to click exactly on the words "Group Body" and then  set the Break Element to LE1, with a Break Value of 0 (zero).

That should get you what I'm showing above.  Hopefully you can figure out how to suprress the repeating of the State values.  This probably requires something like a derived column.

Whoever knows how to suppress the repeating State values and get a report that shows:

AR    3
AZ   10

and so forth, please post the solution!


  
Back to top
IP Logged
 
Journey
Member
*
Offline


No personal text

Posts: 2
Joined: Jan 25th, 2004
Re: Column Report trouble
Reply #2 - Jan 25th, 2004 at 5:44pm
Print Post Print Post  
Thank you TJ, for your detailed post. Yes, your Report works, but that is still not the output I'm looking for...
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Column Report trouble
Reply #3 - Jan 30th, 2004 at 4:37pm
Print Post Print Post  
Journey,

Since you indicated that you would be willing to do this with a mass update, I had Ray The Reaper work up the following code for you. It is written to run against the sample Customers application. It outputs to both the screen (using WriteLn) and to the printer (using PrintString). You can adjust the routine to suit your needs.

In order for this to work, you must sort your records by State.

Note that no line of code should wrap. You may need to unwrap long lines after pasting into Sesame.

** PROGRAMMING SECTION: [ GLOBAL CODE ] [] **
stat sState as String
stat sCount as int
stat sTotal as int

** PROGRAMMING SECTION: [KEY] [Mass Update] **
var vPrint as string
If @ResultSetCurrentPosition() = 1 Then
{
sState = State
sCount = 0
NewPage(850,1100)
PrintString("Number of Clients in Each State", 209, 25, 0, "Arial", 20, 0)
PrintString(" ", 100, 40, 0, "", 0, 0)
}
If State = sState Then
{
sCount = sCount + 1
}
Else
{
WriteLN(sState + "    " + sCount)
PrintString(sState, 100, @PageExtentY() + 2, 40, "Arial", 15, 0)
PrintString(scount, -1, -1, 0, "Arial", 15, 0)
sTotal = sTotal + sCount
sState = State
sCount = 1
}
If @ResultSetCurrentPosition() = @ResultSetTotal() Then
{
WriteLN(sState + "    " + sCount)
PrintString(sState, 100, @PageExtentY() + 2, 40, "Arial", 15, 0)
PrintString(scount, -1, -1, 0, "Arial", 15, 0)
sTotal = sTotal + sCount
PrintString("Total Number of Clients: " + sTotal, 100, @PageExtentY() + 10, 0,
"Arial", 20, 0)
FinishPage()
}
  

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


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Column Report trouble
Reply #4 - Jan 30th, 2004 at 5:40pm
Print Post Print Post  
Could we impose on Ray The Reaper to annotate what each step is doing?  Please Smiley

Thanks
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Column Report trouble
Reply #5 - Jan 30th, 2004 at 6:24pm
Print Post Print Post  
Sure Bob I would be more than happy to.

If @ResultSetCurrentPosition() = 1 Then
{
     sState = State
     sCount = 0
     NewPage(850,1100)
     PrintString("Number of Clients in Each State", 209, 25, 0, "Arial", 20, 0)
     PrintString(" ", 100, 40, 0, "", 0, 0)
}

The above code runs only for the first record. It creates the page, sets a Title for the page which is 2.09 inches to the right of the edge of the paper making it centered, then creates a blank line that is used as a way to force the last y positon of the page down (explanation soon)

If State = sState Then
{
     sCount = sCount + 1
}

If it is in the same state count it as one more from that state.


Else
{
     WriteLN(sState + "    " + sCount)
     PrintString(sState, 100, @PageExtentY() + 2, 40, "Arial", 15, 0)
     PrintString(scount, -1, -1, 0, "Arial", 15, 0)
     sTotal = sTotal + sCount
     sState = State
     sCount = 1
}

Runs when Sesame reaches a different state. Writes the old states name and count to the WriteLn window. Then prints the State name to the Print String page in a column that is 40/100 of an inch wide so the count all appears in one straight column, and that is 2/100 of an inch below the last state which is the last y position(@pageExtentY()). Next the code prints the count of records from that state to the Print String Page. Increases the Total by the count of Records for that State and moves on to the next State.


If @ResultSetCurrentPosition() = @ResultSetTotal() Then
{
     WriteLN(sState + "    " + sCount)
     PrintString(sState, 100, @PageExtentY() + 2, 40, "Arial", 15, 0)
     PrintString(scount, -1, -1, 0, "Arial", 15, 0)
     sTotal = sTotal + sCount
     PrintString("Total Number of Clients: " + sTotal, 100, @PageExtentY() + 10, 0, "Arial", 20, 0)
     FinishPage()
}

This only runs for the last record it does almost the same thing as the code above except does not move on to the next state because there is not one, Adds a Grand total line to the Page below all the state information, and finishes the Print String page causing the page to print to your computer's default printer
« Last Edit: Feb 2nd, 2004 at 2:59pm by Ray the Reaper »  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Column Report troubleWell done! Thank you.
Reply #6 - Jan 30th, 2004 at 6:40pm
Print Post Print Post  
Well done! Cheesy

Thank you very much Ray the Reaper.

This really helps speed up the learning curves.
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Column Report trouble
Reply #7 - Jan 30th, 2004 at 6:50pm
Print Post Print Post  
You are very welcome Bob. I am glad to help speed up learning curves.
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged