Running total with specific criterea
Hey Everyone,
Quick question I hope. I have report that we want to add a running total of all records in the report that contain the numbers 1100 to 1400.
What I have been trying to currently do is create running total sum that uses a formula to evaluate. But the result is that I seem to be totaling just about everything. Thanks very much for any insight tht you can offer.
You'll have to excuse me as I'm not familiar with Basic syntax which is what I am assuming your posted formula is.
It may not make much of a difference but perhaps try the formula in Crystal syntax?
eg.
{QryCrystalReports.CollCD} >= 1100 and {QryCrystalReports.CollCD} <= 1400
Since you said you want this Running Total to check all records that the report pulled for the above-mentioned evaluation formula, I'd probably set the Reset option to "Never" if it has not been done already.
Similar Messages
-
Running total with Layout Editor with BI Publisher 11g
Hello,
I'm trying to create a report with BI Publisher Layout Editor using the "running total" option. My XML looks like this:
<G_1>
<REGION>MZ</REGION>
<G_2>
<INVOICE_NB>1</INVOICE_NB>
<VALUE>1000</VALUE>
</G_2>
<G_2>
<INVOICE_NB>2</INVOICE_NB>
<VALUE>3000</VALUE>
</G_2>
</G_1>
and I want to insert in the layout a data table with this information:
|REGION | RUNNING TOTAL
|MZ | 1000
| | 4000
I inserted a new data table with the region and the value. I grouped the Region to the left (Grouping -> Group Left).
Then I selected the Value column and clicked on Formula -> Running Total, but nothing happened with this last step. Am i forgotting something? How can I display Running Totals on a Data Table with BI Publisher (using Layout editor and not RTF Templates)?
Thank you,
JosepUse the following: Declare a variable before the loop: <?xdoxslt:set_variable($_XDOCTX, 'RTotVar', 0)?>
In your loop: Include the following code for your Running Total Column: <?xdoxslt:set_variable($_XDOCTX, 'RTotVar', xdoxslt:get_variable($_XDOCTX, 'RTotVar') + VALUE)?><?xdoxslt:get_variable($_XDOCTX, 'RTotVar')?>
For an example of the RTF : Look for the files under your local BI Publisher Desktop installation: BI Publisher Desktop\samples\RTF templates\Advanced\Running Total
Thanks,
Bipuser -
I am fairly new to Crystal Reports and Running Totals. I have a group setup that is based on the number of days a loan is late. For example, I have three buckets (30 Days, 60 Days, 90 Days). In setting up the group, I put the group in specific order and decided to exclude the other loans that are less than 30 days. I am trying to get a total $ amount of all the loans instead of just the loans in the buckets. I have searched forums and a Crystal 2008 book trying to figure this out. I tried using a Running Total with the Running Total expert but it is still giving me the same grand $ total that I have for the groups I selected. Any ideas? I am bit confused as to the multipassing of the data. Should I keep the groups setup the way I have them or use the select expert (etc).
Thanks, I am a newbie.i suggest manual running totals, more accurate and if you have duplicate values the summary option will duplicate the data
create 3 formuls
i reset
whileprintingrecords;
numbervar x:= 0;
this gets placed in the group header
calculate
whileprintingrecords;
numbervar x:= x + field or formula;
this gets placed next to the field or formula you want calculated
display
whileprinitngrecords;
numbervar x;
x
this gets displayed in the footer of where the reset is (header)
using manual running totals, if you have data on the report you dont want included you can create a formula that will only calc based upon only what should be included. -
How to create a loop to run total of records for before and after unconstant date
Post Author: Ann2
CA Forum: Formula
Here is the data sample:
ID period code date
1 00 I 01/01/1999
1 00 Z 01/02/1999
1 00 G 12/05/1999
1 00 M 01/01/2000
There are many students with many periods and many codes. I need to save a date when code = 'G' and count separateley records per student/period 2 times - before and equal that date and after that date, so in the end for period 00 I will have 2 values: 3 (before) and 1(after).
There are periods from 00 to 08. I am counting students abscencies before and after warning letter was sent (code G).
The result data should look : 00 01 02 03 04 05 06 07 08 00 01 02 03 04 05 06 07 08 Total
3 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 4
Please help me.
Thank you.
Ann2Post Author: Ann2
CA Forum: Formula
Thank you for your answer, but I do care about the date the 'G' happened, because I need to reset count.
The logic behind is this:if a student absent for more than 8 times per period - the letter will be sent out to the parents , that will be code 'G' with period '-1' (it may happen that there will never be code 'G' , but I need to track all absencies). Once the letter is sent, the count starts over (the count starts over the next day after code 'G'). The absencies which happened before or the date the letter sent should count toward 'previous' abscenices, all other - absenices after the letter.
So basically I need total per period and total per period before or the day with code 'G'. Running total with reset with formula code = 'G' does not work.
I created a formula field which has global date (when code 'G' happenned) and it says if globaldate >= periodDate then date (1900,01,01) else (2100,01,01) and that formula is ok, but I can not use it in running total or can not create group on it and insert total.
Please help me with this. Thank you.
Ann2 -
Post Author: bahamaER
CA Forum: Crystal Reports
Hello, I have been reviewing threads for running totals and would like some assistance on creating a running total for a group with a condition that will display in the group header, the running total should also reset for each group. Is this possible?
I know that there are some constraints such as the variable being reset to 0 in the header for each group as well as the group records have not been rendered when the header formulas are being assessed. I have been able to accomplish the task of running totals with conditions for groups using a running total field and also 3 separate formulas placed in the group header, detail and footer. The display is only correct in the group footer; my goal is to have the footer formula in the group header. Any ideas? I am currently using CR 8.5 but will be upgrading to CR 2008.
ThankyouHi,
If you are trying to calculate Total and display it in Group Header for field value placed in Detail, then you will get incorrect/no value for total, as Crystal Reports prints/processes the report line by line and it will not be able to process the Total for field in Detail section in Group Header.
Its is by Design.
For a workaround:
- Insert the same probematic report (Say A.rpt) as a Subreport in Group Header of this report(Say A.rpt).(Say in GroupHeader A1) and link the Main Report to the
- Insert Section Below (Say GroupHeader A2)
- Calculate Total in Section Group Header A2)
This workaround will reduce the Performance of the report as Subreport will be proceed for each Group Value.
Regards,
Kiran -
Formula Help - Running Total vs ???
Post Author: schilders
CA Forum: Formula
Good Morning All,
I'm creating a report that contains a field called CDM Item. This field indicates whether a particular order set was used for a given record. Valid entries for this field are numeric 6 through 9. I would like to create a formula that tells me the number of records that have a cdm item = 6, another formula that tells me the number of records that have a cdm item = 7 etc. I need to summarize these formulas into pre-defined groups.
I was thinking a running total or a manual running total would be useful here. However, I wanted to get some input from other formula gurus here. Thanks, in advance, for your help.Post Author: yangster
CA Forum: Formula
You don't need to create a manual running total for what you are after.simply create 4 running totals ( 1 for each item number) using a running total with the evaluate formula of cdm = 6 (changed for each number)and resetting after whatever grouping you needthe other alternative you could implement if you have mutliple grouping and wanted subtotals on differing levels is to create a formula for each case such as@case_cdm6if cdm = 6 then 1 else 0then insert sum for each formula on all the differing group levels that way you only have to worry about maintaining one formula if the criteria changes -
Analysis report with totals on specific columns
I have an analysis report that I need to create totals on specific columns. If I turn on "Grand Totals" from the "Edit View: Table" section, all of the numeric columns will display grand totals. This is a nice automatic feature, but I only need totals of specific columns. Not all numeric columns need totals nor do Grand Totals of some columns make any sense.
For example, to display opportunity details, we will have on the report:
Opportunity Name, Item number, Item Description, Quantity, Price, Extended Price
Since the opportunity may have multiple items on it, having a grand total of quantity and unit price makes no sense. All we need is Grand Total of the opportunity extended price.
Is there a way to selectively turn on/off column totals or is it an all or nothing option?
Thanks in advance.
Edited by: nsidev on Sep 1, 2009 10:10 AMActually, i just solved the problem.
Here is what I did:
1. I added a column to the "Design Criteria" section (step 1). To keep the units consistant, I made sure that the data element was suitable for the value (I used a currency element). Ensure you note the position of the new column, mine was in position 11.
2. Under the newly added elements "Column Properties", I set it to HIDDEN and changed the name to "Grand Total"
3. Under the "Edit Formula", I changed the formula to be: SUM(<numeric column>)
4. In "Create Layout" (Step 2), I added a narrative view to the bottom of the page.
5. In the "Edit Narrative View", I set the appropriate formatting and added the following: Total Extended Price: @11
6. Ensure that "Rows to display" is set to 1.
Save and run
All done, works like a charm. -
How can I display the vendor associated with result of my running total sum
I have a report that lists vendors with their most vecent order dates. I need to set up a rotation so that the vendor with the latest order date is next to be selected. I used the running total summary to pick the latest date. How can I display the vendor associated with result of my running total summary?
If your "latest" order date means the "oldest" order date, why don't you try this:
Go to Report tab -> Record Sort Expert -> Choose your order date in ascending order
This will make your oldest order your first record shown.
You can then create a running total count for each record.
Lastly, in your section expert under conditional suppress X+2 formula, write this:
{#CountRecords}>1
The result will only show the oldest record in your report.
I hope that helps,
Zack H. -
Hi, I've created a calcution using the analytic function template "Running Total" and the worksheet ran fine. I saved the workbook with this new calculation.
The next day when I attempt to run that worksheet I received the error "Database Error - ORA-00923 From keyword not found where expected."
For some reason it's loosing the SUM( ) from the calc.
Here's what the calc looks like now -> No of Queries OVER(PARTITION BY Calendar Year and Month ORDER BY Calendar Date ASC ROWS UNBOUNDED PRECEDING )
This is what it looks like when I created it -> SUM(No of Queries) OVER (PARTITION BY Calendar Year and Month ORDER BY Calendar Date ASC ROWS UNBOUNDED PRECEDING)
Brent.Well, I guess my thought process was declaring warrBaseYrPrc in the @currWarrBaseYrPrc formula which would make it a global variable and accessible to all formulas where that same variable is declared. I thought that if I declared warrBaseYrPrc in @currWarr2YrPrc, it would have its value as calculated in @currWarrBaseYrPrc and use that. And since @currWarr2YrPrc returns the variable warrBaseYrPrc with some slight modifications depending on the if statment, it shouldn't have refused use in the Running Total.
So I'm kind of leaning more toward an ordering screw up (i.e. it didn't know what formula to evaluate first because they were all in the same section and dependent on one another because of nesting formula invocations, and thus treated @currWarr2YrPrc warrBaseYrPrc variable, and subsequent calculations, as a constant as you talked about and you can't RT constants). I still find it perplexing why it would treat a variable as a constant, but I guess I'll have to experiment with it a little bit.
By the way, do you know of any good free crystal report debugging tools? -
Hello,
I have a insert from query:
insert into tablexxxx
SELECT ALL G.c1, G.c2,
CASE
WHEN G.colt1 NOT IN ( 'A', 'B', 'C') THEN G.DATA1
WHEN G.colt1 IN ( 'B', 'C') THEN &DATASF
WHEN G.colt1 = 'A' THEN &DATASI
END colt3,
CASE G.colt2 WHEN 'D' THEN G.IMP1 else 0 END IMPD,
CASE G.colt2 WHEN 'A' THEN G.IMP1 else 0 END IMPA,
CASE
WHEN G.colt1 NOT IN ( 'B', 'C')
THEN (&VALU1 -1)
ELSE COLX
END COLX,
FROM table1 G, table2 S, table3 C
WHERE G.colt4 = S.colt4
AND ( (G.colt1 = 'M' AND G.DATA1 BETWEEN &DATA_IP AND &DATA_FP AND G.TCOL6 = EXTRACT(YEAR FROM &DATA_IP) - 1 )
OR (G.colt1 <> 'M' AND G.DATA1 BETWEEN &DATA_IP AND &DATA_FP)
OR (G.colt1 = 'A' AND (&DATASI BETWEEN &DATA_IP AND &DATA_FP AND G.DATA1 = &DATAIE) )
OR (G.colt1 = 'B' AND (&DATASF BETWEEN &DATA_IP AND &DATA_FP AND G.DATA1 = &DATAFE) )
OR (G.colt1 = 'C' AND (&DATASF BETWEEN &DATA_IP AND &DATA_FP AND G.DATA1 = &DATAFE) ) )
AND G.colt5 = C.colt5(+)
ORDER BY 3,4,5 ;
NOW I HAVE TO INSERT in previous query 2 RUNNING TOTALE e.g:
sum(CASE G.colt2 WHEN 'D' THEN G.IMP1 + &myvalue1 else 0 END IMPD) over (order by CASE
WHEN G.colt1 NOT IN ( 'A', 'B', 'C') THEN G.DATA1
WHEN G.colt1 IN ( 'B', 'C') THEN &DATASF
WHEN G.colt1 = 'A' THEN &DATASI
END) running_sum,
sum(CASE G.colt2 WHEN 'A' THEN G.IMP1 + &myvalue2 else 0 END IMPA) over ((order by CASE
WHEN G.colt1 NOT IN ( 'A', 'B', 'C') THEN G.DATA1
WHEN G.colt1 IN ( 'B', 'C') THEN &DATASF
WHEN G.colt1 = 'A' THEN &DATASI
END) running_sum1 Could anyone help me to write it? ( maybe is better write it with SELECT-UNION?)
Thanks in advanceHi IceMan,
I think about having resolved in this way, I don't sincerely believe that is the optimal solution,
but of sure it is that simpler,anyway, one opinion of yours would be very pleasant:
1) I have made an Insert-Select with the 2 runnings total = 0
INSERT INTO TABLEX
SELECT ALL G.c1, G.D2,
CASE
WHEN G.colt1 NOT IN ( 'A', 'B', 'C') THEN G.DATA1
WHEN G.colt1 IN ( 'B', 'C') THEN &DATASF
WHEN G.colt1 = 'A' THEN &DATASI
END D1,
CASE G.colt2 WHEN 'D' THEN G.IMP1 else 0 END IMPD,
CASE G.colt2 WHEN 'A' THEN G.IMP1 else 0 END IMPA,
CASE
WHEN G.colt1 NOT IN ( 'B', 'C')
THEN (&VALU1 -1)
ELSE COLX
END COLX, 0 RUNIMP_D, 0 RUNIMP_A
FROM table1 G, table2 S, table3 C
WHERE ........
ORDER BY 3,4,5 ;2) in the populated table(step 1) I have made an UPDATE-SELECT getting the 2 runnings total
UPDATE TABLEX A SET (RUNIMP_D, RUNIMP_A ) =(
SELECT --G.D1, G.D2, G.IMPD,G.IMPA,
SUM(G.IMPD) OVER (ORDER BY G.D1, G.D2,G.IMPD) RS1 ,
SUM(G.IMPA) OVER (ORDER BY G.D1, G.D2,G.IMPA) RS2
FROM TABLEX G
WHERE G.ROWID = A.ROWID
--ORDER BY 1,2
where G.D1 is that I get from
CASE
WHEN G.colt1 NOT IN ( 'A', 'B', 'C') THEN G.DATA1
WHEN G.colt1 IN ( 'B', 'C') THEN &DATASF
WHEN G.colt1 = 'A' THEN &DATASI
END D1
and
G.IMPD is:
CASE G.colt2 WHEN 'D' THEN G.IMP1 else 0 END IMPDThanks again for your reply -
Running total required but with different timing
Hi All:
I am using Oracle9i Enterprise Edition Release 9.2.0.6.0
I want to write a query to display the statistics report with running total.
I have written following query that return last 60 minutes activities.
SELECT se.tserv_id,
sum(decode(eu.category,'I',1,0)) Imp,
sum(decode(eu.category,'E',1,0)) Exp,
count(*) Total
FROM service_events se, equipment_uses eu
WHERE se.performed BETWEEN trunc(sysdate-60/1440,'mi')
AND trunc(sysdate,'mi')
AND se.tserv_id IN ('EXM','GROUNDED')
AND eu.gkey = se.equse_gkey
AND eu.category IN ('I','E')
GROUP BY se.tserv_id;
now I want to write a query that shows me the result of above query and running total as well
But the different between current activity and running total is as follows
Current Activity = Last 60 minutes activity
Running Total = Total activities from the 08:00 am till sysdate.
for example if this query executed on 11:00 am then the current activity values must be from 10:00 am to 11:00 am and the running total values must be from 08:00 am to 11:00 am
The reason for running total starts at 08:00 am is that the shift starts from 08:00 am to next day 07:59 am.
Can I write one single query for this?
Similarly running total values must be start from last day 08:00 am to current date and time when I executed this query from 00:00 to 08:00 (12 midnight to 8am)
if difficult then plz let me know that how can I find that if the time is from 00 hrs to 08 hrs then start time must be the last date 08:00 am to the current date and time.
Thanks
HassanDear Frnak
Thanks for your reply and help
Its really did what I want
I mean to say that the result format is correct but the value of Total_day column is not correct.
Following is the sample data from 19-Jun-2008 08:00 AM to 20-JUN-2008 08:00 AM
TSERV_ID EQUSE_GKEY PERFORMED
===============================================
EXM 5188958 19-Jun-2008 8:00:32 AM
EXM 5185586 19-Jun-2008 9:03:34 AM
EXM 5181960 19-Jun-2008 9:03:35 AM
EXM 5173333 19-Jun-2008 9:03:35 AM
EXM 5188263 19-Jun-2008 9:08:49 AM
GROUNDED 5174055 19-Jun-2008 9:10:29 AM
GROUNDED 5152887 19-Jun-2008 9:10:29 AM
GROUNDED 5187512 19-Jun-2008 9:10:29 AM
GROUNDED 5196303 19-Jun-2008 9:27:41 AM
EXM 5196370 19-Jun-2008 9:29:50 AM
EXM 5172045 19-Jun-2008 10:01:23 AM
GROUNDED 5196269 19-Jun-2008 11:11:29 AM
GROUNDED 5200219 19-Jun-2008 11:24:39 AM
GROUNDED 5185246 19-Jun-2008 12:06:30 PM
GROUNDED 5190134 19-Jun-2008 12:09:27 PM
GROUNDED 5190475 19-Jun-2008 12:09:27 PM
GROUNDED 5156065 19-Jun-2008 12:26:49 PM
GROUNDED 5132287 19-Jun-2008 1:56:44 PM
EXM 5189203 19-Jun-2008 2:29:17 PM
EXM 5180158 19-Jun-2008 3:27:03 PM
EXM 5149310 19-Jun-2008 3:37:31 PM
EXM 5196303 19-Jun-2008 3:42:48 PM
EXM 5192768 19-Jun-2008 4:03:51 PM
EXM 5174055 19-Jun-2008 4:14:23 PM
EXM 5200231 19-Jun-2008 4:45:51 PM
EXM 5157151 19-Jun-2008 4:51:06 PM
EXM 5159930 19-Jun-2008 5:01:36 PM
EXM 5185237 19-Jun-2008 5:01:37 PM
EXM 5195434 19-Jun-2008 5:01:37 PM
EXM 5152887 19-Jun-2008 5:06:49 PM
EXM 5196269 19-Jun-2008 5:06:49 PM
EXM 5187512 19-Jun-2008 5:17:26 PM
EXM 5190134 19-Jun-2008 5:59:24 PM
GROUNDED 5101919 19-Jun-2008 6:44:36 PM
GROUNDED 5101918 19-Jun-2008 6:44:37 PM
GROUNDED 5101913 19-Jun-2008 6:44:37 PM
EXM 5185735 19-Jun-2008 6:46:38 PM
GROUNDED 5195475 19-Jun-2008 6:47:11 PM
GROUNDED 5195361 19-Jun-2008 6:47:12 PM
EXM 5132608 19-Jun-2008 7:02:23 PM
GROUNDED 5195334 19-Jun-2008 7:10:32 PM
GROUNDED 5190558 19-Jun-2008 7:10:32 PM
EXM 5183029 19-Jun-2008 7:33:53 PM
EXM 5183480 19-Jun-2008 7:39:12 PM
EXM 5189566 19-Jun-2008 8:00:11 PM
EXM 5181825 19-Jun-2008 8:15:57 PM
EXM 5183537 19-Jun-2008 8:15:57 PM
EXM 5180210 19-Jun-2008 9:08:27 PM
GROUNDED 5193136 19-Jun-2008 9:58:23 PM
EXM 5171510 19-Jun-2008 10:21:59 PM
EXM 5185615 19-Jun-2008 10:48:14 PM
EXM 5184737 19-Jun-2008 10:53:29 PM
EXM 5195475 19-Jun-2008 11:51:16 PM
EXM 5195476 20-Jun-2008 12:01:46 AM
EXM 5190558 20-Jun-2008 12:12:17 AM
EXM 5196473 20-Jun-2008 12:54:19 AM
EXM 5183204 20-Jun-2008 1:20:34 AM
GROUNDED 5192844 20-Jun-2008 1:28:24 AM
GROUNDED 5174238 20-Jun-2008 1:28:24 AM
GROUNDED 5193127 20-Jun-2008 1:28:24 AM
GROUNDED 5185794 20-Jun-2008 1:29:09 AM
GROUNDED 5192895 20-Jun-2008 3:04:23 AM
GROUNDED 5193039 20-Jun-2008 3:04:23 AM
GROUNDED 5195447 20-Jun-2008 3:04:23 AM
GROUNDED 5190228 20-Jun-2008 3:04:24 AM
GROUNDED 5179370 20-Jun-2008 3:04:24 AM
GROUNDED 5190289 20-Jun-2008 3:04:24 AM
GROUNDED 5174065 20-Jun-2008 3:04:24 AM
GROUNDED 5192862 20-Jun-2008 5:04:42 AM
GROUNDED 5199903 20-Jun-2008 5:04:42 AM
EXM 5178176 20-Jun-2008 6:30:29 AM
EXM 5185161 20-Jun-2008 6:46:14 AM
EXM 5180226 20-Jun-2008 6:46:14 AM
GROUNDED 5202026 20-Jun-2008 7:03:14 AM
EXM 5101912 20-Jun-2008 7:07:14 AM
GROUNDED 5176763 20-Jun-2008 7:25:27 AM
GROUNDED 5185494 20-Jun-2008 7:25:27 AM
EXM 5185295 20-Jun-2008 7:38:46 AM
EXM 5173837 20-Jun-2008 7:49:15 AM
GKEY CATEGORY
=================
5101912 I
5101913 I
5101918 I
5101919 I
5132287 I
5132608 I
5149310 I
5152887 I
5156065 I
5157151 I
5159930 I
5171510 I
5172045 I
5173333 I
5173837 I
5174055 I
5174065 I
5174238 I
5176763 I
5178176 I
5179370 I
5180158 I
5180210 I
5180226 I
5181825 I
5181960 I
5183029 I
5183204 I
5183480 I
5183537 I
5184737 I
5185161 I
5185237 I
5185246 I
5185295 I
5185494 I
5185586 I
5185615 I
5185735 I
5185794 I
5187512 I
5188263 I
5188958 I
5189203 I
5189566 I
5190134 I
5190228 I
5190289 I
5190475 I
5190558 I
5192768 I
5192844 I
5192862 I
5192895 I
5193039 I
5193127 I
5193136 I
5195334 I
5195361 I
5195434 I
5195447 I
5195475 I
5195476 I
5196269 I
5196303 I
5196370 I
5196473 I
5199903 I
5200219 E
5200231 E
5202026 EAnd I used the same query suggested by you.
WITH s AS(
SELECT se.tserv_id , eu.category ,
CASE
WHEN se.performed BETWEEN
to_date('&target_dt','DD-MON-RRRR HH24:MI') - (1/24)
AND to_date('&target_dt','DD-MON-RRRR HH24:MI')
THEN 1
ELSE 0
END AS in_hour ,
CASE
WHEN TRUNC (se.performed - (8/24)) = TRUNC (to_date('&target_dt','DD-MON-RRRR HH24:MI')
- (8/24))
THEN 1
ELSE 0
END AS in_day
FROM service_events se , equipment_uses eu
WHERE eu.gkey = se.equse_gkey
AND eu.category IN ('I', 'E')
AND se.tserv_id in ('EXM','GROUNDED')
SELECT tserv_id,
SUM (DECODE (category, 'I', in_hour)) AS imp_hour,
SUM (DECODE (category, 'E', in_hour)) AS exp_hour,
SUM (in_hour) AS total_hour,
SUM (in_day) AS total_day
FROM s
GROUP BY tserv_idNow you have the sample data for almost 24 hours
Let me clear it again
When I executed this query at 20-JUN-2008 09:00 AM it gives me following result (that is accurate)
TSERV_ID IMP_HOUR EXP_HOUR TOTAL_HOUR TOTAL_DAY
EXM 2 0 2 3
GROUNDED 1 0 1 8When I executed this query between 20-JUN-2008 00:00 to 20-JUN-2008 08:00
then system must show the Total_Day value from 19-JUN-2008 08:00 to current date and time. e.g
I executed this query at 20-JUN-2008 06:00 AM it gives me following result:
TSERV_ID IMP_HOUR EXP_HOUR TOTAL_HOUR TOTAL_DAY
EXM 0 0 0 44
GROUNDED 2 0 2 35Now here you can see that the value of Total_Day is not as accurate as I required:
EXM = 44 and GROUNDED = 35
these values are between 19-JUN-2008 00:00 to 20-JUN-2008 06:00 (that is wrong in my case)
The values of total_day should be as follows as 8 hours from 00:00 to 07:59 AM fall in the shift of 18-JUN-2008 not in 19-JUN-2008
From 19-JUN-2008 08:00 to 20-JUN-2008 06:00
EXM: 38
GROUNDED: 32
Plz note that this result is required because in our company the shift starts from 08:00 AM and ends 07:59 AM next day
I hope you will be more clear now and there is no confusion anymore.
Plz let me know if you still confused.
Brgs, -
Associate a record name with a running total in Report Footer
Please Help!
I have a report that returns records for the most recent order recieved by vendor.
The page header displays Vendor, Contact, Order #, and date
I did a group by Vendor
I used a running total on the order date
with a summary of minimum
that evaluates on change of group
Reset never
This returns the last order date for the vendor with the oldest order
How can I get the vendors name that is associated with the oldest order date to display in the Rport Footer.Please follow the following steps: I tested it and it works.You dont need to use running total.
1. Add the Vendor,Contact,Order #, Order Date to Details Section (u can delete them if not needed from details section)
2. Create a Group on Vendor.
3. Add a Summary i.e. Minimum(Order Date)
4. Copy this summary to Group Header if you want or just let it be in the Group Footer Section
5. Add a SubReport in the Report Footer Section.
6.The Subreport Should be based on the Command like:
SELECT `Orders`.`Customer ID`, `Orders`.`Order Date`
FROM `Orders` `Orders`
WHERE `Orders`.`Order Date`=
SELECT MIN(`Orders`.`Order Date`)
FROM `Orders` `Orders`)
7. Refresh the Report and you will see that Report Footer section displays all the vendors with minimum order date along with their name.
One more thing to keep in mind is that more than one vendor might have the same minimum order date. -
Help with a resetting running total
Hi, I need help with a query that will have a running total that resets at certain points
Version
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production sample data
create table t ( stat varchar2(3)
, beg_dt date
, end_dt date
, dur number);
Insert into t values ('ACT',to_date('01-JUL-2012','DD-MON-YYYY'),to_date('31-JUL-2012','DD-MON-YYYY'),31);
Insert into t values ('ACT',to_date('01-AUG-2012','DD-MON-YYYY'),to_date('31-AUG-2012','DD-MON-YYYY'),31);
Insert into t values ('ACT',to_date('01-SEP-2012','DD-MON-YYYY'),to_date('30-SEP-2012','DD-MON-YYYY'),30);
Insert into t values ('LOA',to_date('01-OCT-2012','DD-MON-YYYY'),to_date('25-OCT-2012','DD-MON-YYYY'),25);
Insert into t values ('LOA',to_date('26-OCT-2012','DD-MON-YYYY'),to_date('31-OCT-2012','DD-MON-YYYY'),6);
Insert into t values ('LOA',to_date('01-NOV-2012','DD-MON-YYYY'),to_date('04-NOV-2012','DD-MON-YYYY'),4);
Insert into t values ('ACT',to_date('05-NOV-2012','DD-MON-YYYY'),to_date('10-NOV-2012','DD-MON-YYYY'),6);
Insert into t values ('LOA',to_date('11-NOV-2012','DD-MON-YYYY'),to_date('30-NOV-2012','DD-MON-YYYY'),20);
Insert into t values ('LOA',to_date('01-DEC-2012','DD-MON-YYYY'),to_date('15-DEC-2012','DD-MON-YYYY'),15);
Insert into t values ('ACT',to_date('16-DEC-2012','DD-MON-YYYY'),to_date('31-DEC-2012','DD-MON-YYYY'),16);
Insert into t values ('LOA',to_date('01-JAN-2013','DD-MON-YYYY'),to_date('31-JAN-2013','DD-MON-YYYY'),31);
Insert into t values ('LOA',to_date('01-FEB-2013','DD-MON-YYYY'),to_date('05-FEB-2013','DD-MON-YYYY'),5);
Insert into t values ('LOA',to_date('06-FEB-2013','DD-MON-YYYY'),to_date('15-FEB-2013','DD-MON-YYYY'),10);
Insert into t values ('LOA',to_date('16-FEB-2013','DD-MON-YYYY'),to_date('25-FEB-2013','DD-MON-YYYY'),10);
Insert into t values ('LOA',to_date('26-FEB-2013','DD-MON-YYYY'),to_date('28-FEB-2013','DD-MON-YYYY'),3);
Insert into t values ('LOA',to_date('01-MAR-2013','DD-MON-YYYY'),to_date('10-MAR-2013','DD-MON-YYYY'),10);
Insert into t values ('ACT',to_date('11-MAR-2013','DD-MON-YYYY'),to_date('31-MAR-2013','DD-MON-YYYY'),21);
Insert into t values ('ACT',to_date('01-APR-2013','DD-MON-YYYY'),to_date('30-APR-2013','DD-MON-YYYY'),30);
Insert into t values ('LOA',to_date('01-MAY-2013','DD-MON-YYYY'),to_date('25-MAY-2013','DD-MON-YYYY'),25);
Insert into t values ('LOA',to_date('26-MAY-2013','DD-MON-YYYY'),to_date('31-MAY-2013','DD-MON-YYYY'),6);
Insert into t values ('LOA',to_date('01-JUN-2013','DD-MON-YYYY'),to_date('04-JUN-2013','DD-MON-YYYY'),4);
Insert into t values ('ACT',to_date('05-JUN-2013','DD-MON-YYYY'),to_date('30-JUN-2013','DD-MON-YYYY'),26);This is close.
select stat
, beg_dt
, end_dt
, dur
, sum( case stat when 'LOA' then dur else 0 end ) over ( partition by stat order by beg_dt) tot1
from t
order by beg_dt
STAT BEG_DT END_DT DUR TOT1
ACT 01-JUL-2012 31-JUL-2012 31 0
ACT 01-AUG-2012 31-AUG-2012 31 0
ACT 01-SEP-2012 30-SEP-2012 30 0
LOA 01-OCT-2012 25-OCT-2012 25 25
LOA 26-OCT-2012 31-OCT-2012 6 31
LOA 01-NOV-2012 04-NOV-2012 4 35
ACT 05-NOV-2012 10-NOV-2012 6 0
LOA 11-NOV-2012 30-NOV-2012 20 55
LOA 01-DEC-2012 15-DEC-2012 15 70
ACT 16-DEC-2012 31-DEC-2012 16 0
LOA 01-JAN-2013 31-JAN-2013 31 101
LOA 01-FEB-2013 05-FEB-2013 5 106
LOA 06-FEB-2013 15-FEB-2013 10 116
LOA 16-FEB-2013 25-FEB-2013 10 126
LOA 26-FEB-2013 28-FEB-2013 3 129
LOA 01-MAR-2013 10-MAR-2013 10 139
ACT 11-MAR-2013 31-MAR-2013 21 0
ACT 01-APR-2013 30-APR-2013 30 0
LOA 01-MAY-2013 25-MAY-2013 25 164
LOA 26-MAY-2013 31-MAY-2013 6 170
LOA 01-JUN-2013 04-JUN-2013 4 174
ACT 05-JUN-2013 30-JUN-2013 26 0 I need a running total of LOA stat that will reset itself with each break of ACT so that I get :
STAT BEG_DT END_DT DUR TOT1
ACT 01-JUL-2012 31-JUL-2012 31 0
ACT 01-AUG-2012 31-AUG-2012 31 0
ACT 01-SEP-2012 30-SEP-2012 30 0
LOA 01-OCT-2012 25-OCT-2012 25 25
LOA 26-OCT-2012 31-OCT-2012 6 31
LOA 01-NOV-2012 04-NOV-2012 4 35
ACT 05-NOV-2012 10-NOV-2012 6 0
LOA 11-NOV-2012 30-NOV-2012 20 20
LOA 01-DEC-2012 15-DEC-2012 15 35
ACT 16-DEC-2012 31-DEC-2012 16 0
LOA 01-JAN-2013 31-JAN-2013 31 31
LOA 01-FEB-2013 05-FEB-2013 5 36
LOA 06-FEB-2013 15-FEB-2013 10 46
LOA 16-FEB-2013 25-FEB-2013 10 56
LOA 26-FEB-2013 28-FEB-2013 3 59
LOA 01-MAR-2013 10-MAR-2013 10 69
ACT 11-MAR-2013 31-MAR-2013 21 0
ACT 01-APR-2013 30-APR-2013 30 0
LOA 01-MAY-2013 25-MAY-2013 25 25
LOA 26-MAY-2013 31-MAY-2013 6 31
LOA 01-JUN-2013 04-JUN-2013 4 35
ACT 05-JUN-2013 30-JUN-2013 26 0 Any help would be appreciated, thanks.Hi,
So, you want a separate total whenever there's an 'ACT'. That's what PARTITION BY is for. You need to add the number of ACTs already encountered (which I called act_cnt) to the PARTITION BY clause that gets you the SUM.
We can get act_cnt using the analytic functions like COUNT or SUM, but, since one analytic function can't depend on another computed inthe same query, we need to use a sub-query to compute act_cnt.
Here's one way:
WITH got_act_cnt AS
SELECT stat, beg_dt, end_dt, dur
, COUNT (CASE WHEN stat = 'ACT' THEN 1 END)
OVER (ORDER BY beg_dt) AS act_cnt
FROM t
SELECT stat, beg_dt, end_dt, dur
, SUM (CASE stat WHEN 'LOA' THEN dur ELSE 0 END)
OVER ( PARTITION BY stat
, act_cnt -- ***** NEW *****
ORDER BY beg_dt
) AS totl
FROM got_act_cnt
ORDER BY beg_dt
;Are 'ACT' and 'LOA' the only possible values for stat? If so, the query above can probably be simplified. -
How to create crystal report 2008 with running totals?
i want to create a report with running totals as follows:
Balance B/F 1000.00
Invoices Receipts Running B/ce
100 1100
500 600
500 100
300 400
400 0
The B/F field is passed as a Parameter.Hi panayiotis,
In order to create a running total you need to have absolute clarity on the following:
(i)Whether the running total be set on change of field/record/group.
(ii)Whether the running total be set on change of record/group OR never.
Make the appropriate choice.
Apply this to the field to summarize and type of summary in Running Total Pane.
Thanks,
Amogh. -
I'm having some trouble getting the correct number when a drive has multiple incentives associated with the drive. And to explain as fully as I can, every drive has a projecture procedure count and when complete, a performed procedure count associated with the drive. And when a drive has an incentive assigned to it, I would like to count the drive's projected and performed procedure count to the incentive count. In the screen shot, there are five drives with four each having one incentive to the drive. The incentive count in which only one incentive is assigned to one drive is correct, but the Fandango pre-drive and post-drive counts are off because it is not counting the 12 and 15 that were collected on the bottom drive.
For my running total, I am summing the ProceduresPerformed field, evaluating on the change of field of DriveID (each drive) and reseting on the change of field for EquipmentID (each incentive has its own unique ID).
What would be the best way to handle drives with multiple incentives to get the correct count?Hello DJ,
Let me see if I can explain more clearly to help you understand.
I think the most important thing is that each drive is unique and will have one projected procedure number and one performed procedure number. But each drive may have multiple incentives assigned to each drive. Where I run into trouble is when I have more than one incentive on a drive.
I'll try to illustrate below:
Drive
Projected
Performed
Incentive(s):
A
10
12
Movie Tickets
Gift Card
B
5
10
Movie Tickets
Beach Towel
C
20
25
Gift Card
Based on these entries, what I'm trying to have summarized should look like this:
Pre-Drive (Sum of Projected)
Post-Drive (Sum of Performed)
Movie Tickets
15
22
Gift Card
30
37
Beach Towel
5
10
So if an incentive is assigned to a drive, I would like to have all of the projected and performed numbers summarized that the particular incentive appears on. Hopefully this makes sense.
And one last screen shot here of a query I ran against the database to illustrate how a drive can have multiple incentives on the drive.
Maybe you are looking for
-
Hello, I have a HP Officejet Pro 8500 All-in-One Printer - A909a and I am trying to connect my ipad mini to that, for scanning purpose. I downloaded the the HP e-print and HP AIO remote apps and unfortunately I was not able to scan the pictures yet.
-
Transfering music from an android to my iPod Touch
I have a Pantech Burst P9070, an iPod Touch 4th gen using IOS 6.1.2, a laptop running Ubuntu 14.04 and an 8GB micro SD card. I have all the music I want on my Ubuntu laptop and my Pantech Burst running Android 2.3.5. Is there anyway I could get my mu
-
Blackmagic intensity pro drivers download ubuntu 14.04
You can download drivers off of the manufacturer site http://www.blackmagicdesign.com/support
-
AppleCare coverage of Time Capsule ordered w/ Macbook
Apple sales & Apple Store say that if I buy Time Capsule w/ a Macbook & AppleCare, AppleCare Protection will cover the Time Capsule. But it is not written anywhere that I can find in their online terms and conditions. I believe there is language abou
-
My phone restart automatic when i shut it down !!!! WHY
i have I phone 4S when i shut it down its restart automatic i do not know why , even lock key work perfect