Keeping a Running Total for Formula fields
Post Author: khanh
CA Forum: Formula
I've been messing around for the past couple of days trying to figure out what the best approach for my problem. So here is what I'm trying to accomplish. I have multiple rows which contains sums for different columns and one of the columns contains the maximum of the sums.
For example:
ROW 1 SUM (A) SUM(B) SUM(C) MAX(sum(a), sum(b), sum(c))<----
Formula Variable 1
ROW 2 SUM (A) SUM(B) SUM(C) MAX(sum(a), sum(b), sum(c))<----
Formula Variable 2
ROW Total SUM (1A2A) SUM(1B2B) SUM(1C+2C) Result of Row 1 + Result of Row 2
What I did was create a formula variable that evaluates the maximum of those rows and have a summary row, that keeps a running total. I'm not sure how to store the result of that formula variable in the running total since the formula variable isn't an option to select. Does anyone have a suggestions if this is a good approach or if there's another way to approach it?
For each value you enter into scores.text, end it with a
+"\n"
as in...
scores.text = String(1100) + "\n";
scores.text += String(2200) + "\n";
scores.text += String(1500) + "\n";
Similar Messages
-
How to Summarized Running Total and Formula ????
Post Author: ryan_r
CA Forum: Crystal Reports
Hi my name is Ryan, I want to ask something. I have build a report
that contains Running totals and Formula. What I want to do is I want
to use subtotal and Summary field for the running total and Formula,
but I can find the field when I click the dropdownlist in the Subtotal
dialog box or summary field for the running total and the formula. Is
there any way that I can use subtotal or summary field for Running
Totals and formula, I do need some help guys, Thanks. FYI: I use Visual Studio.NET 2003; ASP.NET(C#).regardsPost Author: ryan_r
CA Forum: Crystal Reports
Hi kcheeb, thanks for your advice but it doesn't work sorry. By the way maybe I can explain you more of twisted situation.I have updated my report,
so im not using runningtotals any more, I'm using summary field and
formula which are;-the summary field is "Sum of SuspenseVoucher.Realisation" located in Group Footer #3: SuspenseMstr.ProgramID-The formula is "@Balance_Formula" which contain:{SuspenseMstr.Budget}
- Sum ({SuspenseVoucher.PenggunaanBudget}, {SuspenseMstr.ProgramID})
also located in the same location as summary field above.FYI: I have three group records which are:-Group #1 : SuspenseMstr.APDate (Appearing in months e.g January 2007)-Group
#2 : programCategoryMstr.programCategoryID (doesn't have any objects I
just put some dashed line, the group is only for proper sorting)-Group #3: SuspenseMstr.ProgramIDwhat I want to do is:-in the Group Footer #3, I already put "Sum of SuspenseVoucher.Realisation" and "@Balance_formula"-in
the Group Footer #2, I want to put Summary of Budget but there's a
problem in here too, in the budget field there are some data are
conditionally suppressed. I already tried to put some summary field but
the summary operation wasn't like what I wanted. What I wanted was the
sum only evaluate the data that appeared in the report not the
suppressed, but in the summary the suppressed data keep evaluated. And
in this location I also want to put Summary of "Sum of
SuspenseVoucher.Realisation" and the Sum of the @Balance_formula.-
in the Group Footer #1, I want to add some Summary of "Sum of Budget"
(which I already explained that this operation has a problem) and I
also want to put the Sum of "Summary of Sum of
SuspenseVoucher.Realisation" and the Sum of "Sum of @Balance_formula"-And in the Report Footer I want to add some Grand Total from all of the evaluation above.So
there are my problems, quite much I would say. I hope this explanation
helping all of you guys to solve my problem, thanks for spending your
valuable time for me. This matter is really important for me 'cause I
want to learn something new from all of you experts as I'm still a
"toddler" in this situation and also because I work in this field, so a
BIG thank you for all of you guys out there. Best Regards. -
Alv subtotals and grand total for a field
Hi friends,
I Have an internal table ITAB1
in that i have a senario as below.
In my GRID display iam getting values in the layou as follows
BUKRS = 1000
LIFNR MATNR STCST
100 abc 500,00
100 pqr 400,00
100 xyz 200,00
sub total
200 pto 700,00
200 vbr 900,00
sub total
BUKRS = 2000
LIFNR MATNR STCST
150 abc 500,00
150 pqr 400,00
150 xyz 200,00
sub total
260 pto 700,00
260 vbr 900,00
sub total
GRAND TOTAL =
Now my requirement is at the end of every vendor i need sub total for STCST field.
and at the end of every company code i need GRAND TOTAL for STCST field.
Its alv grid display.
how can i do that.
Regards,
Priyanka.Check this sample code may it will help u:
*& Report Z_ALV_SUBTOTAL
REPORT z_alv_subtotal.
*& Table declaration
TABLES: ekko.
*& Type pool declaration
TYPE-POOLS: slis. " Type pool for ALV
*& Selection screen
SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.
*& Type declaration
* Type declaration for internal table to store EKPO data
TYPES: BEGIN OF x_data,
ebeln TYPE char30, " Document no.
ebelp TYPE ebelp, " Item no
matnr TYPE matnr, " Material no
matnr1 TYPE matnr, " Material no
werks TYPE werks_d, " Plant
werks1 TYPE werks_d, " Plant
ntgew TYPE entge, " Net weight
gewe TYPE egewe, " Unit of weight
END OF x_data.
*& Internal table declaration
DATA:
* Internal table to store EKPO data
i_ekpo TYPE STANDARD TABLE OF x_data INITIAL SIZE 0,
* Internal table for storing field catalog information
i_fieldcat TYPE slis_t_fieldcat_alv,
* Internal table for Top of Page info. in ALV Display
i_alv_top_of_page TYPE slis_t_listheader,
* Internal table for ALV Display events
i_events TYPE slis_t_event,
* Internal table for storing ALV sort information
i_sort TYPE slis_t_sortinfo_alv,
i_event TYPE slis_t_event.
*& Work area declaration
DATA:
wa_ekko TYPE x_data,
wa_layout TYPE slis_layout_alv,
wa_events TYPE slis_alv_event,
wa_sort TYPE slis_sortinfo_alv.
*& Constant declaration
CONSTANTS:
c_header TYPE char1
VALUE 'H', "Header in ALV
c_item TYPE char1
VALUE 'S'.
*& Start-of-selection event
START-OF-SELECTION.
* Select data from ekpo
SELECT ebeln " Doc no
ebelp " Item
matnr " Material*
matnr " Material*
werks " Plant*
werks " Plant*
ntgew " Quantity
gewei " Unit
FROM ekpo
INTO TABLE i_ekpo
WHERE ebeln IN s_ebeln
AND ntgew NE '0.00'.
IF sy-subrc = 0.
SORT i_ekpo BY ebeln ebelp matnr .
ENDIF.
* To build the Page header
PERFORM sub_build_header.
* To prepare field catalog
PERFORM sub_field_catalog.
* Perform to populate the layout structure
PERFORM sub_populate_layout.
* Perform to populate the sort table.
PERFORM sub_populate_sort.
* Perform to populate ALV event
PERFORM sub_get_event.
END-OF-SELECTION.
* Perform to display ALV report
PERFORM sub_alv_report_display.
*& Form sub_build_header
* To build the header
* No Parameter
FORM sub_build_header .
* Local data declaration
DATA: l_system TYPE char10 , "System id
l_r_line TYPE slis_listheader, "Hold list header
l_date TYPE char10, "Date
l_time TYPE char10, "Time
l_success_records TYPE i, "No of success records
l_title(300) TYPE c. " Title
* Title Display
l_r_line-typ = c_header. " header
l_title = 'Test report'(001).
l_r_line-info = l_title.
APPEND l_r_line TO i_alv_top_of_page.
CLEAR l_r_line.
* Run date Display
CLEAR l_date.
l_r_line-typ = c_item. " Item
WRITE: sy-datum TO l_date MM/DD/YYYY.
l_r_line-key = 'Run Date :'(002).
l_r_line-info = l_date.
APPEND l_r_line TO i_alv_top_of_page.
CLEAR: l_r_line,
l_date.
ENDFORM. " sub_build_header
*& Form sub_field_catalog
* Build Field Catalog
* No Parameter
FORM sub_field_catalog .
* Build Field Catalog
PERFORM sub_fill_alv_field_catalog USING:
'01' '01' 'EBELN' 'I_EKPO' 'L'
'Doc No'(003) ' ' ' ' ' ' ' ',
'01' '02' 'EBELP' 'I_EKPO' 'L'
'Item No'(004) 'X' 'X' ' ' ' ',
'01' '03' 'MATNR' 'I_EKPO' 'L'
'Material No'(005) 'X' 'X' ' ' ' ',
'01' '03' 'MATNR1' 'I_EKPO' 'L'
'Material No'(005) ' ' ' ' ' ' ' ',
'01' '04' 'WERKS' 'I_EKPO' 'L'
'Plant'(006) 'X' 'X' ' ' ' ',
'01' '04' 'WERKS1' 'I_EKPO' 'L'
'Plant'(006) ' ' ' ' ' ' ' ',
'01' '05' 'NTGEW' 'I_EKPO' 'R'
'Net Weight'(007) ' ' ' ' 'GEWE' 'I_EKPO'.
ENDFORM. " sub_field_catalog
*& Form sub_fill_alv_field_catalog
*& For building Field Catalog
*& p_rowpos Row position
*& p_colpos Col position
*& p_fldnam Fldname
*& p_tabnam Tabname
*& p_justif Justification
*& p_seltext Seltext
*& p_out no out
*& p_tech Technical field
*& p_qfield Quantity field
*& p_qtab Quantity table
FORM sub_fill_alv_field_catalog USING p_rowpos TYPE sycurow
p_colpos TYPE sycucol
p_fldnam TYPE fieldname
p_tabnam TYPE tabname
p_justif TYPE char1
p_seltext TYPE dd03p-scrtext_l
p_out TYPE char1
p_tech TYPE char1
p_qfield TYPE slis_fieldname
p_qtab TYPE slis_tabname.
* Local declaration for field catalog
DATA: wa_lfl_fcat TYPE slis_fieldcat_alv.
wa_lfl_fcat-row_pos = p_rowpos. "Row
wa_lfl_fcat-col_pos = p_colpos. "Column
wa_lfl_fcat-fieldname = p_fldnam. "Field Name
wa_lfl_fcat-tabname = p_tabnam. "Internal Table Name
wa_lfl_fcat-just = p_justif. "Screen Justified
wa_lfl_fcat-seltext_l = p_seltext. "Field Text
wa_lfl_fcat-no_out = p_out. "No output
wa_lfl_fcat-tech = p_tech. "Technical field
wa_lfl_fcat-qfieldname = p_qfield. "Quantity unit
wa_lfl_fcat-qtabname = p_qtab . "Quantity table
IF p_fldnam = 'NTGEW'.
wa_lfl_fcat-do_sum = 'X'.
ENDIF.
APPEND wa_lfl_fcat TO i_fieldcat.
CLEAR wa_lfl_fcat.
ENDFORM. " sub_fill_alv_field_catalog
*& Form sub_populate_layout
* Populate ALV layout
* No Parameter
FORM sub_populate_layout .
CLEAR wa_layout.
wa_layout-colwidth_optimize = 'X'." Optimization of Col width
ENDFORM. " sub_populate_layout
*& Form sub_populate_sort
* Populate ALV sort table
* No Parameter
FORM sub_populate_sort .
* Sort on material
wa_sort-spos = '01' .
wa_sort-fieldname = 'MATNR'.
wa_sort-tabname = 'I_EKPO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.
* Sort on plant
wa_sort-spos = '02'.
wa_sort-fieldname = 'WERKS'.
wa_sort-tabname = 'I_EKPO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.
ENDFORM. " sub_populate_sort
*& Form sub_get_event
* Get ALV grid event and pass the form name to subtotal_text
* event
* No Parameter
FORM sub_get_event .
CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE
'SUBTOTAL_TEXT'.
DATA: l_s_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 4
IMPORTING
et_events = i_event
EXCEPTIONS
list_type_wrong = 0
OTHERS = 0.
* Subtotal
READ TABLE i_event INTO l_s_event
WITH KEY name = slis_ev_subtotal_text.
IF sy-subrc = 0.
MOVE c_formname_subtotal_text TO l_s_event-form.
MODIFY i_event FROM l_s_event INDEX sy-tabix.
ENDIF.
ENDFORM. " sub_get_event
*& Form sub_alv_report_display
* For ALV Report Display
* No Parameter
FORM sub_alv_report_display .
DATA: l_repid TYPE syrepid .
l_repid = sy-repid .
* This function module for displaying the ALV report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
i_callback_top_of_page = 'SUB_ALV_TOP_OF_PAGE'
is_layout = wa_layout
it_fieldcat = i_fieldcat
it_sort = i_sort
it_events = i_event
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = i_ekpo
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE i000 WITH 'Error in ALV report display'(055).
ENDIF.
ENDFORM. " sub_alv_report_display
* FORM sub_alv_top_of_page
* Call ALV top of page
* No parameter
FORM sub_alv_top_of_page. "#EC CALLED
* To write header for the ALV
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_alv_top_of_page.
ENDFORM. "alv_top_of_page
*& Form subtotal_text
* Build subtotal text
* P_total Total
* p_subtot_text Subtotal text info
FORM subtotal_text CHANGING
p_total TYPE any
p_subtot_text TYPE slis_subtot_text.
* Material level sub total
IF p_subtot_text-criteria = 'MATNR'.
p_subtot_text-display_text_for_subtotal
= 'Material level total'(009).
ENDIF.
* Plant level sub total
IF p_subtot_text-criteria = 'WERKS'.
p_subtot_text-display_text_for_subtotal = 'Plant level total'(010).
ENDIF.
ENDFORM. "subtotal_text
Edited by: Joyjit Ghosh on Aug 21, 2008 5:25 PM -
Is it possible to create an invoive that keeps a running total in one column and in another column keep total of monies spent from a starting amount of funding?
Hi Sara,
Many thanks for your reply. We just brought Adobe Acrobat XI Pro complete
with Adobe Forms Central, My manager asked whether I could use the forms
part to create a summary tracking sheet for all of our contracts.
Having looked at it I could see how to create a table that in the first
column deleted costs from a starting fund, and in the last keeps a running
total of all monies spent.
I agree, Excel does seem to be much better suited to the task. I was try
trying to comply with her request
Regards, -
I have to create a programme in java where you input type of currency, exchange rate, amout of currency. then convert it to GBP and print the answers. This bit I have done. A loop is also needed to keep inputting amounts of the same currency and keep a running total of amount input.
The programme runs fine, and I can get the total number of transactions, but I am having problems getting the amount of currency inputted to add. I created a new variable for this but cant get it to work, it will either print out 0 or the last amount inputted, depending what I do.
Any help would be appreciated. I know its probably very simple but I have spent so long on this I think I have lost my way.You need to create the summation variable before the loop and use it inside the loop, so that it doesn't keep getting created (and the data held in it erased) with each iteration of the loop.
If this is not clear, then post your code.
Good luck! -
How to set a new value for formula field in crystal reports xi?
<p>How to set a new value for formula field in crystal reports xi?</p><p>//formula</p><p>{@description}</p><p> </p><p>exemplo in VB6</p><p>crxSubreport.FormulaFields.Item(1).Text = "'Subreport Formula'" or</p><p>crxSubreport.FormulaFields.Item("description").Text = "'Subreport Formula'"</p><p>How to in JRC?</p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p>
Hi,
This functionality is known to be very important and is a key part of the next major release of the JRC planned for the first half of 2008.
Regards,
<p>Blair Wheadon</p>
<p>Product Manager, Crystal Reports</p> -
Running total for duplicate rows
Hi,
I am trying to write an sql which shows the running total for records which has duplicate. Please share any idea to get this.
sample rows:
col1 col2 col3
1 A 2
1 A 2
1 A 2
1 B 3
1 B 3
1 C 5
1 D 2
1 D 2o/p required:
col1 col2 col3 cumulative_tot
1 A 2 2
1 A 2 2
1 A 2 2
1 B 3 5
1 B 3 5
1 C 5 10
1 D 2 12
1 D 2 12Hi,
Try this:
WITH A AS
select 1 col1, 'A' col2, 2 col3 from dual union all
select 1 col1, 'A' col2, 2 col3 from dual union all
select 1 col1, 'A' col2, 2 col3 from dual union all
select 1 col1, 'B' col2, 3 col3 from dual union all
select 1 col1, 'B' col2, 3 col3 from dual union all
select 1 col1, 'C' col2, 5 col3 from dual union all
select 1 col1, 'D' col2, 2 col3 from dual union all
select 1 col1, 'D' col2, 2 col3 from dual
,B AS
SELECT
A.*
,ROW_NUMBER() OVER (PARTITION BY COL1, COL2 ORDER BY 1) RN
FROM
A
SELECT
B.*
,SUM(CASE WHEN RN = 1 THEN COL3 ELSE 0 END) OVER ( ORDER BY COL1, COL2 ,RN ) cumulative_tot
FROM
B
COL1 COL2 COL3 RN CUMULATIVE_TOT
1 A 2 1 2
1 A 2 2 2
1 A 2 3 2
1 B 3 1 5
1 B 3 2 5
1 C 5 1 10
1 D 2 1 12
1 D 2 2 12
8 rows selected Regards,
Peter -
Subtotal and grand total for two fields(iseg-buchm and iseg-erfmg)
hi experts,
how to do subtotal and grand total for two fields (iseg-buchm and iseg-erfmg).please help me on solving the problem.subtotal & grand total can be done in folowing way in ALV.
1.Pass it_sort parametere to REUSE_ALV_GRID_DISPLAY
2.Give the field name for sorting in it_sort-fieldname. it can be any field name u want to sort ur data with.
3.For iseg-buchm & iseg-erfmg mark do_sum = 'X'. in fieldcat
gs_sort-spos = 1.
gs_sort-fieldname = 'ANY FIELD NAME'.
gs_sort-up = 'X'.
gs_sort-subtot = 'X'.
APPEND gs_sort TO et_sort.
IF iv_fieldname = 'BUCHM'
OR iv_fieldname = 'ERFMG'.
gs_fieldcat-do_sum = 'X'.
ENDIF.
APPEND gs_fieldcat TO gt_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_variant = ev_variant
it_fieldcat = gt_fieldcat[] -
Running total of calculated field in pivot
VERSION: ORACLE 11
TABLE:
create table chart_detail (
DIS NUMBER,
BLD_MO VARCHAR2(7),
BLD NUMBER(10),
RPLC NUMBER(10));DATA:
insert into chart_detail values (60,'2011-03',0,2);
insert into chart_detail values (150,'2011-04',10572,0);
insert into chart_detail values (120,'2011-04',26449,5);
insert into chart_detail values (30,'2011-04',0,1);
insert into chart_detail values (60,'2011-04',0,7);
insert into chart_detail values (90,'2011-04',0,9);
insert into chart_detail values (120,'2011-05',5714,0);
insert into chart_detail values (90,'2011-05',24557,1);
insert into chart_detail values (60,'2011-05',0,4);
insert into chart_detail values (30,'2011-05',0,0);
COMMIT;EXPECTED RESULTS:
2011-04 2011-05
DIS RPLC BLD TBLD IPTV RPLC BLD TBLD IPTV
30 1 0 37021 0.03 0 0 30271 0.00
60 7 0 37021 0.22 4 0 30271 0.13
90 9 0 37021 0.46 1 24557 30271 0.17
120 5 26449 37021 0.59 0 5714 5714 0.17
150 0 10572 10572 0.59 0
180 0 0
TOTAL 22 37021 5 30271 PROBLEM: I need to have a running total of IPTV like in the above example. I can get the IPTV for each DIS/bld_mo but I don't know how to get the running total of it. In the script below I just used an example where I tried summing the IPTV like was done for build. I know it can't be done that way because IPTV is a calculated field in the query but if I substitute "APR_IPTV" with the formula for IPTV I get an error that window functions aren't allowed here. I do not know a way around this. I commented out the bad piece of code.
PROBLEM SCRIPT:
WITH pivot_results AS
SELECT dis
, NVL (apr11_rep, 0) AS apr11_rep
, NVL (apr11_bld, 0) AS apr11_bld
, NVL ( SUM (apr11_bld)
OVER (ORDER BY dis DESC)
, 0
) AS apr11_tbld
, DECODE(NVL ( SUM (apr11_bld)
OVER (ORDER BY dis DESC)
, 0),0,0,ROUND(NVL(apr11_rep, 0)*1000/ NVL ( SUM (apr11_bld)
OVER (ORDER BY dis DESC)
, 0),2
)) AS apr11_iptv
, NVL ( SUM (apr11_iptv)
OVER (ORDER BY dis DESC)
, 0
) AS apr11_tiptv
, NVL (may11_rep, 0) AS may11_rep
, NVL (may11_bld, 0) AS may11_bld
, NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0
) AS may11_tbld
, DECODE(NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),2
)) AS may11_iptv
, DECODE(NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),2
)) AS may11_tiptv
FROM chart_detail
PIVOT ( MAX (rplc) AS rep
, MAX (bld) AS bld
FOR bld_mo IN ( '2011-04' AS apr11
, '2011-05' AS may11
SELECT CASE
WHEN GROUPING (dis) = 0
THEN TO_CHAR (dis)
ELSE 'Total'
END AS dis
, SUM (apr11_rep) AS apr11_rep
, SUM (apr11_bld) AS apr11_bld
, SUM (apr11_tbld) AS apr11_tbld
, CASE
WHEN GROUPING (dis) = 0
THEN SUM (apr11_iptv)
END AS apr11_iptv
, SUM (apr11_tiptv) AS apr11_tiptv
, CASE
WHEN GROUPING (dis) = 0
THEN SUM (apr11_tpiptv)
END AS apr11_tiptv
, SUM (may11_rep) AS may11_rep
, SUM (may11_bld) AS may11_bld
, SUM (may11_tbld) AS may11_tbld
, CASE
WHEN GROUPING (dis) = 0
THEN SUM (may11_iptv)
END AS may11_iptv
FROM pivot_results
GROUP BY ROLLUP (dis)
ORDER BY pivot_results.dis
;Thank you,Hi,
So you know how to compute iptv for an individual row; the problem now is that you want to get a running total of iptv; is that it?
The problem there is that computing iptv requires an analytic function, and analytic functions can't be nested. To get the results of nesting f (g (x)), where f and g are analytic funtions, you have to compute g in a sub-query, and then use the results as the argument to f in a super-query.
Here's how to apply that to your situation:
WITH pivot_results AS
SELECT dis
-- April, 2011
, NVL (apr11_rep, 0) AS apr11_rep
, NVL (apr11_bld, 0) AS apr11_bld
, NVL ( SUM (apr11_bld)
OVER (ORDER BY dis DESC)
, 0
) AS apr11_tbld
, NVL ( 1000 * apr11_rep
/ NULLIF ( SUM (apr11_bld) OVER (ORDER BY dis DESC)
, 0
, 0
) AS apr11_iptv
-- May, 2011
, NVL (may11_rep, 0) AS may11_rep
, NVL (may11_bld, 0) AS may11_bld
, NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0
) AS may11_tbld
, NVL ( 1000 * may11_rep
/ NULLIF ( SUM (may11_bld) OVER (ORDER BY dis DESC)
, 0
, 0
) AS may11_iptv
FROM chart_detail
PIVOT ( MAX (rplc) AS rep
, MAX (bld) AS bld
FOR bld_mo IN ( '2011-04' AS apr11
, '2011-05' AS may11
SELECT CASE
WHEN GROUPING (dis) = 0
THEN TO_CHAR (dis)
ELSE 'Total'
END AS dis
-- April 2011
, SUM (apr11_rep) AS apr11_rep
, SUM (apr11_bld) AS apr11_bld
, SUM (apr11_tbld) AS apr11_tbld
, CASE
WHEN GROUPING (dis) = 0
THEN ROUND ( SUM (SUM (apr11_iptv))
OVER (ORDER BY dis)
, 2
END AS apr11_iptv
-- May 2011
, SUM (may11_rep) AS may11_rep
, SUM (may11_bld) AS may11_bld
, SUM (may11_tbld) AS may11_tbld
, CASE
WHEN GROUPING (dis) = 0
THEN ROUND ( SUM (SUM (may11_iptv))
OVER (ORDER BY dis)
, 2
END AS may11_iptv
FROM pivot_results
GROUP BY ROLLUP (dis)
ORDER BY pivot_results.dis
;Output:
APR11 APR11 APR11 APR11 MAY11 MAY11 MAY11 MAY11
DIS _REP _BLD _TBLD _IPTV _REP _BLD _TBLD _IPTV
30 1 0 37021 .03 0 0 30271 .00
60 7 0 37021 .22 4 0 30271 .13
90 9 0 37021 .46 1 24557 30271 .17
120 5 26449 37021 .59 0 5714 5714 .17
150 0 10572 10572 .59 0 0 0 .17
Total 22 37021 158656 5 30271 96527As you can see, this is not quite what you wanted on the row where dis='150'. You asked for NULLS in the may11_rep, may11_bld and may11_iptv columns. You can get those results if you need them; just explain the rules that govern whether to display the values and when to display NULL.
The way you posted the sample data and results, and the quantity of sample data were all excellent; it really helped me find a solution. Thanks.
It would have also helped it you had explained how iptv is computed. Basically, iptv = 1000 * rep / tbld, right?
It looks like most of this code:
, DECODE(NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),2
)) AS may11_iptvwas a way of avoiding divide by 0 errors; it would have been helpful if you had explained that. -
Running Total Grouping Formula
I have a running total condition that I need to summarize the field CAWP.BAC. I would typicaly evaluate this total for change of group 4 and reset on change of group 3. I need to condition the evaluation for ".900" in {CAWP.WP} but i also need to evaluate for change of group 4. Does any one have any examples of a formula for evaluation "on change of group"?
Hi John,
For this you can try using manual running total formula's.
1) Create a @reset formula as below and place it in group header 3.
Formula :
Whileprintingrecords;
Numbervar i:=0;
2) Create an @evaluation formula and place it in detail section.
Formula:
whileprintingrecords;
numbervar i;
if {CAWP.WP} = ".900" then
i:= i+ {CAWP.BAC}
3) Create a @display formula and place it in group footer 4.
Formula:
whileprintingrecords;
numbervar i;
Hope this will help!!
Regards,
Vinay -
Running total for item availbe qty. from On Hand - SO + PO by promise date
I stuck with Balance(running total).
How to link item number with SO and PO?
Need daily item qty. available qty from "On Hand" Qty. + PO - SO by promise date and sort by ascending?
Item# Order Date SO/PO PromiseDate Qty Bal.
AE01 08/01/08 OnHand 20 20
08/02/08 SO#1877 08/05/08 -3 17
08/04/08 SO#2044 08/08/08 -6 11
07/22/08 PO#632 08/10/08 10 21
Thanks.create a group by promise date
2nd group by po#
put the fields either in the group or in the details
PO#, PO promise date, qty and SO#, SO promise date, qty then availability qty
manual running totals
create 3 formulas
1 reset
WHILEPRINTINGRECORDS;
NUMBERVAR ITEMLOC := 0;
place in the group header on what you want the total to reset by (po#)
1 calc
WHILEPRINTINGRECORDS;
NUMBERVAR ITEMLOC := ITEMLOC +(qty};
this gets placed where the calculate will take place (next to qty)
1 display
WHILEPRINTINGRECORDS;
NUMBERVAR ITEMLOC;
ITEMLOC
this gets placed in the group footer.
for each field that gets calculated by a group create 3 formulas for each
they need to have the same variable name to reference each other.
if you need to create a 2nd set to calc something else give that a new variable name. -
Running total condition formula
Hi all!! I am trying to have a running total based on some conditions but my formula is not working. Mabey someone has some idea how to approach this problem
{CAWP.C7}="committed.aic" or
{CAWP.C7}="committed.anic" and {TPHASE.CECODE}<>"bonds" or
{CAWP.C7}="committed.anic" and {TPHASE.CECODE}<>"conserv" or
{CAWP.C7}="committed.anic" and {TPHASE.CECODE}<>"const contingency" or
{CAWP.C7}="committed.close" or
{CAWP.C7}="committed.sunk"
I am looking to sum only the records that test for all "committed.anic" and not include the "bonds","conserv","const contingency" etc..... from another table
does any one have any ideas of how to approach this?????Try this using braces for each condition
{CAWP.C7}="committed.aic" or
({CAWP.C7}="committed.anic" and {TPHASE.CECODE}"bonds") or
({CAWP.C7}="committed.anic" and {TPHASE.CECODE}"conserv") or
({CAWP.C7}="committed.anic" and {TPHASE.CECODE}"const contingency" )or
{CAWP.C7}="committed.close" or
{CAWP.C7}="committed.sunk"
Regards,
Raghavendra -
Running Total for "cleared balance"
I want to produce query that will produce two running totals. The 1st once is straight forward and is 'Ledger Balance' - that is the balance after a particular transaction has taken place on that day. The Cleared Balance is the running total balance accounting for the value date of a transaction. For example a transaction for today, say $50 may be value dated tomorrow and hence is included in the Ledger Balance but would not appear in the Cleared balance until tomorrow.
Lets try and use some simple data:
TransactionsTable
Tran_ID TranDate ValueDate Amount
1 01/02/2004 01/02/2004 50
2 01/02/2004 01/02/2004 25
3 01/02/2004 05/02/2004 30
4 01/02/2004 01/02/2004 55
5 02/02/2004 04/02/2004 11
6 02/02/2004 02/02/2004 23
7 02/02/2004 02/02/2004 33
8 02/02/2004 02/02/2004 47
9 04/02/2004 04/02/2004 10
10 07/02/2004 07/02/2004 5
StatementHistory
AC_No Start_Date End_Date Opening_Ledger Opening_Cleared
55 02/02/2004 02/02/2004 160 130
55 04/03/2004 04/02/2004 274 233
Assuming that the account opened on the 01/02/04 with a zero balance.
So for a daily statement on the 01/02/04, I'd expect to see the following Details
TranDate ValueDate Amount Ledger Balance Cleared Balance
01/02/2004 01/02/2004 50 50 50
01/02/2004 01/02/2004 25 75 75
01/02/2004 05/02/2004 30 105 75
01/02/2004 01/02/2004 55 160 130
So for a daily statement on the 02/02/04, I'd expect to see the following Details
TranDate ValueDate Amount Ledger Balance Cleared Balance
02/02/2004 04/02/2004 11 171 130
02/02/2004 02/02/2004 23 194 153
02/02/2004 02/02/2004 33 227 186
02/02/2004 02/02/2004 47 274 233
And skipping to the 04/02/04, I'd expect to see.
04/02/2004 04/02/2004 10 284 254
I can get the ledger balance using:
sum(amount_to_account) OVER (PARTITION BY ac_no , trans_ID
ORDER BY TranDate, trans_ID
RANGE UNBOUNDED PRECEDING)
+ sh.Opening_Ledger
But I'm unsure how to get the Cleared balance as this need to access transaction inforation from a number of days previous (possibly up to 5 days allowing for maximum period for clearing a transaction).
Does anyone have an idea how to achive this?Hi,
Try this:
WITH A AS
select 1 col1, 'A' col2, 2 col3 from dual union all
select 1 col1, 'A' col2, 2 col3 from dual union all
select 1 col1, 'A' col2, 2 col3 from dual union all
select 1 col1, 'B' col2, 3 col3 from dual union all
select 1 col1, 'B' col2, 3 col3 from dual union all
select 1 col1, 'C' col2, 5 col3 from dual union all
select 1 col1, 'D' col2, 2 col3 from dual union all
select 1 col1, 'D' col2, 2 col3 from dual
,B AS
SELECT
A.*
,ROW_NUMBER() OVER (PARTITION BY COL1, COL2 ORDER BY 1) RN
FROM
A
SELECT
B.*
,SUM(CASE WHEN RN = 1 THEN COL3 ELSE 0 END) OVER ( ORDER BY COL1, COL2 ,RN ) cumulative_tot
FROM
B
COL1 COL2 COL3 RN CUMULATIVE_TOT
1 A 2 1 2
1 A 2 2 2
1 A 2 3 2
1 B 3 1 5
1 B 3 2 5
1 C 5 1 10
1 D 2 1 12
1 D 2 2 12
8 rows selected Regards,
Peter -
Running Totals and Formulas with Cross Tabs
Hi,
I'm using Crystal Reports 2008 and am having two issues using Cross Tabs.
The first is that I want to have two crosstabs. They both will have a common Y axis (Oppourtunity.Sales Rep), and on the Y Axis I want one to show all (Opportunity.Create Date) where (Opportunity.Staus = Won) and the other where (Opportunity.Staus = In Process), but I can't figure out how to contruct the formula to return this result.
The other issue, is that in addition to summarizing based on Sum (Opportunity.Expected Revenue), I would also like to create a running total to show the cumulative (Expected Revenue) Week over Week.
Any direction would be fantastic.
Thank you,
MichaelPlease go through the SAP Notes listed here which would help you how to create mannual running totals in crosstab
[https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_ossnotes&query=runningtotalin+crosstab&adv=true¬e_number=&component=&sdn_updated_on_comparator=GE&sdn_updated_on=&sortby=cm_rnd_rankvalue]
Regards,
Raghavendra -
Expense Report Export Program keeps on running normally for hours
Hi and assalam o alay kum Gurus
I am facing a problem in creating of invoice through expense report export program, I create expense report and run the program "Expense Report Export" but the issue is the program keeps on running for several hours we also raised SR for this issue but no solution provided after 6 months.
We are currently on R 12.1.2 can any one please guide me what to do, maybe any some one faced the same issue before, I really need your help just to check whether I missed any setup part or this is some kind of bug.
Best Regards
Danish.Did you ever find a solution to this question? My internet expense templates are set to receipts are required for CASH and CREDIT CARD over a certain amount. Also, internet expense setup and admin is set to place the report on hold if receipt has not been received. I ran the Expense Report Export and they imported even though receipts were not received. Thank you.
Maybe you are looking for
-
My MacBook Pro is running very hot after lion install. Are there any hardware changes that will help? What can I do to get it back to normal?
-
Create new iCal event as easily as Outlook?
Is there a way to create an event in iCal like Outlook? I may be missing something. Outlook - click once on the day and type iCal - click twice on the day, then click once on the event name, then type (I know there is a keyboard equivalent, but that
-
Error in submiting request set from Daily Business Intelligence Administrat
I am getting the following error when submitting "ADS Incremental Financials Request Group" request set from "Daily Business Intelligence Administrator" responsibility in vision R12 instance : APP-FND-01564: ORACLE error -1116 in SUBMIT: others Cause
-
im new to a mac and am using pages for a report but noticed that there is a large space after i put in an apostrophe or quotation marks...is there any way to get rid of them? or does this not show up when i print my document?
-
Installing SF302-08p with VOIP and Vlans
I am installing this switch to a new departement. The reason of this is to share networks and bring POE over there as we will be istalling VOIP phones next month. We already have a network in place: -Cisco me 3400 from the ISP -Cisco ASA 5510 firewal