Create daily report using crosstabs - crystal-reports

I know that crosstabs are just for summaries. But is it possible to use a crosstab for daily reports given two dates? It's more like a details summary.
For example:
Date: 10 August 2012
Start Date: 10/8/2012
End Date: 11/8/2012
Date: 10 August 2012
_________| Center 1 | Center 2 | Total |
Person 1 | 1 | 2 | 3 |
Person 2 | 2 | 5 | 7 |
TOTAL | 3 | 7 | 10 |
Date: 11 August 2012
_________| Center 1 | Center 2 | Total |
Person 1 | 5 | 2 | 7 |
Person 2 | 8 | 5 | 13 |
TOTAL | 13 | 7 | 20 |

Unfortunately, you'd have to have each date as a row in the crosstab, and I think this is the best you'll be able to get:
10 August 2012|_________| Center 1 | Center 2 | Total |
|Person 1 | 1 | 2 | 3 |
|Person 2 | 2 | 5 | 7 |
|TOTAL | 3 | 7 | 10 |
11 August 2012|_________| Center 1 | Center 2 | Total |
|Person 1 | 5 | 2 | 7 |
|Person 2 | 8 | 5 | 13 |
|TOTAL | 13 | 7 | 20 |
|GRAND | 16 | 14 | 30 |
|TOTAL | | | |
So your setup would be:
Center Total
----+--------+-------+------+
Date| | | |
|Person | | |

Related

Architecture Design for Bus Routing with Time

This is to confirm if my design is good enough or get the better ideas to solve the bus routing problem with time. Here is my solution with the primary steps given below:
Have one edges table which represents all the edges (the source and target represent vertices (bus stops):
postgres=# select id, source, target, cost from busedges;
id | source | target | cost
----+--------+--------+------
1 | 1 | 2 | 1
2 | 2 | 3 | 1
3 | 3 | 4 | 1
4 | 4 | 5 | 1
5 | 1 | 7 | 1
6 | 7 | 8 | 1
7 | 1 | 6 | 1
8 | 6 | 8 | 1
9 | 9 | 10 | 1
10 | 10 | 11 | 1
11 | 11 | 12 | 1
12 | 12 | 13 | 1
13 | 9 | 15 | 1
14 | 15 | 16 | 1
15 | 9 | 14 | 1
16 | 14 | 16 | 1
Have a table which represents bus details like from time, to time, edge etc.
NOTE: I have used integer format for "from" and "to" column for faster results as I can do an integer query, but I can replace it with any better format if available.
postgres=# select id, "busedgeId", "busId", "from", "to" from busedgetimes;
id | busedgeId | busId | from | to
----+-----------+-------+-------+-------
18 | 1 | 1 | 33000 | 33300
19 | 2 | 1 | 33300 | 33600
20 | 3 | 2 | 33900 | 34200
21 | 4 | 2 | 34200 | 34800
22 | 1 | 3 | 36000 | 36300
23 | 2 | 3 | 36600 | 37200
24 | 3 | 4 | 38400 | 38700
25 | 4 | 4 | 38700 | 39540
Use dijkstra algorithm to find the nearest path.
Get the upcoming buses from the busedgetimes table in the earliest first order for the nearest path detected by dijkstra algorithm. => This leads to a bit complex query though.
Can I do any kind of improvements to this, or are there any better designs?
Links to docs, articles related to this would be really helpful.
This is totally normal and the regular way to do it. See also,
PgRouting Example

Spotfire - Calculate average only if there are minimum 3 values

I want to create a cross table in Spotfire where in which Average is calculated only when there are at least 3 values. If there are no values or less than 3 values the average should be blank.
+-------+-----+---------+
| Month | Age | Average |
+-------+-----+---------+
| 1 | 10 | |
| 2 | 11 | |
| 3 | 2 | 7.7 |
| 4 | | |
| 5 | 13 | |
| 6 | 14 | |
| 7 | | |
| 8 | 19 | |
| 9 | 20 | |
| 10 | 21 | 20 |
+-------+-----+---------+
If I'm understanding you correctly, you want to group by Month, and then have something like this as your aggregation:
If(Count()>2,Avg([Age]),null) as [AverageAge_3Min]

Tibco Spotfire - Calculate average only if there are minimum 3 values in a column - see desc

I want to calculate average in Spotfire only when there are minimum 3 values. if there are no values or just 2 values the average should be blank
Raw data:
Product Age Average
1
2
3 10
4 12
5 13 11
6
7 18
8 19
9 20 19
10 21 20
The only way I could really do this is with 3 calculated columns. Insert these calculated columns in this order:
If(Min(If([Age] IS NULL,0,[Age])) over (LastPeriods(3,[Product]))<>0,1) as [BitFlag]
Avg([Age]) over (LastPeriods(3,[Product])) as [TempAvg]
If([BitFlag]=1,[TempAvg]) as [Average]
This will give you the following results. You can ignore / hide the two columns you don't care about.
RESULTS
+---------+-----+---------+------------------+------------------+
| Product | Age | BitFlag | TempAvg | Average |
+---------+-----+---------+------------------+------------------+
| 1 | | | | |
| 2 | | | | |
| 3 | 10 | | 10 | |
| 4 | 12 | | 11 | |
| 5 | 13 | 1 | 11.6666666666667 | 11.6666666666667 |
| 6 | | | 12.5 | |
| 7 | 18 | | 15.5 | |
| 8 | 19 | | 18.5 | |
| 9 | 20 | 1 | 19 | 19 |
| 10 | 21 | 1 | 20 | 20 |
| 11 | | | 20.5 | |
| 12 | 22 | | 21.5 | |
| 13 | 36 | | 29 | |
| 14 | | | 29 | |
| 15 | 11 | | 23.5 | |
| 16 | 23 | | 17 | |
| 17 | 14 | 1 | 16 | 16 |
+---------+-----+---------+------------------+------------------+

emacs org mode: how do i refer to the current row number?

i would like to use the current row number of my org table in cell calculations, either in relation to the table as a whole or in relation to an hline.
if i have the following table:
|---+---+---|
| x | y | z |
|---+---+---|
| 2 | 4 | 8 |
| 2 | 4 | 8 |
| 2 | 4 | 8 |
| 2 | 4 | 8 |
| 2 | 4 | 8 |
| 2 | 4 | 8 |
| 2 | 4 | 8 |
| 2 | 4 | 8 |
| 2 | 4 | 8 |
|---+---+---|
#+TBLFM: #II..#III$1=2::$2=4::$3=$1*$2
how do I change it so that the in the y column each cell is equal to its table row number, as shown if you turn on grid mode in org? the resulting table would look like:
|---+----+----|
| x | y | z |
|---+----+----|
| 2 | 2 | 4 |
| 2 | 3 | 6 |
| 2 | 4 | 8 |
| 2 | 5 | 10 |
| 2 | 6 | 12 |
| 2 | 7 | 14 |
| 2 | 8 | 16 |
| 2 | 9 | 18 |
| 2 | 10 | 20 |
|---+----+----|
(defmath passIndex (x)
x
)
Number rows:
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
#+TBLFM: $1=passIndex(##)
Number columns:
| 1 | 2 | 3 | 4 | 5 |
#+TBLFM: #1=passIndex($#)
Number rows with header row:
| header |
|--------|
| 2 |
| 3 |
| 4 |
| 5 |
#+TBLFM: $1=passIndex(##)

How to fill right in org-mode?

Perhaps I missed this in the documentation but can Anyone point Me in the direction of how to fill right a series of columns in emacs's org-mode? I believe I saw how to fill down but do not recall seeing how to fill right.
Edit: For example, I am looking for a way to take:
| 8 | 6 | 7 | 5 | 3 | 0 | 9 |
| :=#1$1*2 | | | | | | |
And turn it into:
| 8 | 6 | 7 | 5 | 3 | 0 | 9 |
| :=#1$1*2 | :=#1$2*2 | :=#1$3*2 | :=#1$4*2 | :=#1$5*2 | :=#1$6*2 | :=#1$7*2 |
Which evaluates to:
| 16 | 12 | 14 | 10 | 6 | 0 | 18 |
Starting with this state:
| 8 | 6 | 7 | 5 | 3 | 0 | 9 |
| | | | | | | |
#+TBLFM: #2=#1*2
You get to this state:
| 8 | 6 | 7 | 5 | 3 | 0 | 9 |
| 16 | 12 | 14 | 10 | 6 | 0 | 18 |
#+TBLFM: #2=#1*2
by pressing C-c C-c while on the line with TBLFM.