Calculating Average dynamically in BW Report

Hello experts,
I need to create a report where in I need to display month wise billing qty along with the average qty,
here 'billing qty' is a key figure and "avgqty" should be calculated dynamically.
The formula for avgqty is :
"average qty" = ("beginning qty" + "n" stock at month's end)/(n+1) where n is the monthly duration that the user gives in the selection.
ex: if the user put from "01/2006" to "03/2006" in the selection screen for the  Calendar Year/Month  then  here n becomes 2, so:
"avgqty" = (total qty for jan + total qty for feb + total qty for mar )/(2+1)
Can some please let me know the procedure on how to pass this "n" value to the formula that I need to use for my "avgqty" calculation.  
Thanks & Regds

Hi Murali,
i assuming You have your Month variable (MONTH)( user/entry).
First create 1 Customer Exit variable (CUMMONTH)with interval value. Go to CMOD and write this code.
DATA: L_S_RANGE TYPE RSR_S_RANGESID.
DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.
CASE I_VNAM.
WHEN 'CUMMONTH'.
IF I_STEP = 2.
"after the popup
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = 'MONTH'.
CLEAR L_S_RANGE.
L_S_RANGE-LOW = LOC_VAR_RANGE-LOW."low value = input L_S_RANGE-HIGH = LOC_VAR_RANGE-HIGH. "high value = input L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
APPEND L_S_RANGE TO E_T_RANGE.
EXIT.
ENDLOOP.
ENDIF.
ENDCASE.
Now create a selection which have this variable CUMMONTH.( so that you get the summation of total qty from jan to qty of mar)
Now, come to your (n+1) part.
Create a formula variable (FUMMONTH)again customer exit having single value.
write this code. (not full code ..try in your system)
char l(1),
char h(1).
CASE I_VNAM.
WHEN 'FUMMONTH'.
IF I_STEP = 2.
"after the popup
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = 'MONTH'.
CLEAR L_S_RANGE.
lm = LOC_VAR_RANGE-LOW+4(2)."low value = input month
hm = LOC_VAR_RANGE-HIGH+4(2). "high value = input month
ly = LOC_VAR_RANGE-LOW(4)."low value = input year
hy = LOC_VAR_RANGE-HIGH(4). "high value = input year
'write logic
'for if user enter from 2005(ly) to 2006(hy)..
' subtract h-l and give it L_S_RANGE-LOW
L_S_RANGE-LOW = subtract
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
APPEND L_S_RANGE TO E_T_RANGE.
EXIT.
ENDLOOP.
ENDIF.
ENDCASE.
after this..
Make a Formula named Avg Qty
=NODIV((That selection)(name of formula variable +1))
Hope i m clear.
Regards,
San!
Message was edited by: San!

Similar Messages

  • Calculating Average Days in Crystal Reports using a Visual FoxPro driver

    Post Author: sher
    CA Forum: Crystal Reports
    I use the following code in a crystal XI report to calculate average days between two dates using the sql server driver.  It worked fine.  I used the same code in a crystal XI program using a visual FoxPro driver.  It does not work.  Can someone help me with code needed to calculate average days using a visual foxpro driver?
    cast ( Avg( DateDiff( DD, CREDENTIALING.APPLICATION_RECEIVED, ENTITYASSIGNMENTS.STATUSASOF )) As int ) AS AvgDaysFromReceipt,
    cast ( Sum( DateDiff( DD,CREDENTIALING.APPLICATION_RECEIVED, ENTITYASSIGNMENTS.STATUSASOF)) As int )  AS TotDaysFromReceipt

    Not sure if this is any simpler but you could save this as a custom function, that way you will have to modify it once a year for the holidays.
    numbervar days;
    datevar date1 := minimum({?My Parameter});
    datevar date2 := maximum({?My Parameter});
    days := DateDiff ("d", date1, date2) -
    DateDiff ("ww", date1, date2, crSaturday) -
    DateDiff ("ww", date1, date2, crSunday);    // this will give you the number of business days
                                                        // (excluding Saturdays and Sundays) for a given date range.
    // then, for each holiday, you can enter lines like this
    if date(2008,01,01) in {?My Parameter} then days := days - 1;
    // The final tally of DAYS should give you the total business days in a date range.
    totext(days,0);
    where {?My Parameter} is the date range.

  • Dynamic seleciton in report variant FBL1N

    Hi,
    Problem Description
    I am trying use dyanamic selection in report variant of FBL1N but its not working.
    My working
    I am using dyanamic date variant.
    In the selection screen of FBL1N, we have posting date in dynamic selections.
    While creating a variant for the selection screen of FBL1N, I am selecting Posting Date of dyanamic selection and choosing selection variant as "D" (D: Dynamic date calculation) along with Current Date as variable.
    However system is not accepting this and the current date is not coming up while choosing this variant.
    Solution required
    Can anyone please help me out with dyanamic date calculation in dates from dynamic selection in report FBL1N.
    Thanks,
    Nitish

    Dear
    You did not specify in which version you are working.  If you are in new GL instead of using FBL1N you can as well use T.Code S_AC0_52000888 and here you can make dynamic selections.
    Regds

  • Applying a Template to a Dynamic PL/SQL Report

    I have an application in which there are several reports, all based on the wizard and using standard templates.
    One of my reports, however is a Dynamic PL/SQL Report, using htp.print statements to create the output.
    I'm not quite sure, how I can specify that I want to use the same template as the rest of my reports, so as to maintain the look and feel of the whole application.
    Can someone tell me how this is done, or where I can read about it?
    Thank you.

    Sergio,
    I have a table with two columns I want to display. The columns aren't wide but there are 15 or 20 rows. What I would like is that after 10 rows the report starts another set of colums beside the first ones. The standard report continues on down so you have to scroll down to see the bottom. I'm not sure if my explanation is clear so instead of:
    1 info1
    2 info2
    3 info3
    4 info4
    5 info5
    6 info6
    I want:
    1 info1 4 info4
    2 info2 5 info5
    3 info3 6 info6
    Not being too picky, it could also be:
    1 info1 2 info2
    3 info3 4 info4
    5 info5 6 info6
    I don't see a way of doing this with standard reporting so a PL/SQL report seems to be the way to go (which works fine except for the formatting). Sorry if I've just missed it in the options. I'd prefer to do it using standard HTMLDB
    Thanks.
    Paul

  • Share  calculation  Not working in the report

    Iam surprised not to ge the simple share calculation not working at my report.
    I have a dimension and corresponding values ( measures) .I made a Total at the end of the report. and I want to calcualte share of Total to each corresponding value.
    how to do this, any thougts,...
    I have used calculated memebers for this, But I wan to make the percentage of the total ( which is calculated inside Tool itself)
    Please help....

    Prassad,
    Not totally sure what you are trying to achieve but there a couple of possible solutions:
    1) Total = total of all dimension members. Assuming you only have three dimension members then you should have a fourth member called ALL_DIMS or something similar. In the Share calculation template you need to specify the Total level as the basis for your share calc. This will generate the following result:
                             Revenue  % Share
    - All Members     600         100%
         A                  100           17%
         B                  200           33%
         C                  300           50%2) The total you are referring to is in fact a sub total and is the result of adding together only the results for A + B + C, i.e. you have hundreds of dimension members but you specifically want to see a total for just these three members. To do this create a new custom aggregate call "My Total" and add together the dimension members A + B + C - Custom Aggs are a new feature to Discoverer OLAP (Checkout Mark Rittman's excellent blog article for more information on this feature: http://www.rittmanmead.com/2006/11/13/checking-out-the-new-discoverer-101220-features/)
    Then in the Share calculation wizard set the basis for your index using the last option in the list "Specific Dimension Member" and select your new custom aggregate member.
    Hope this helps
    Keith Laker
    Oracle EMEA Consulting
    BI Blog: http://oraclebi.blogspot.com/
    DM Blog: http://oracledmt.blogspot.com/
    BI on Oracle: http://www.oracle.com/bi/
    BI on OTN: http://www.oracle.com/technology/products/bi/
    BI Samples: http://www.oracle.com/technology/products/bi/samples/

  • How to show the columns dynamically in OBIEE report based on the selection?

    Hi,
    I have a requirement where the columns should be dynamically shown in report based on what we select in propmt page.
    I'm creating a report in OBIEE where i want to give an option to the end user to select the columns whichever he wants to see in the report.
    For example I have the following columns in the report already:
    Customer Name,
    Customer Number,
    Bank Account,
    Address
    I want to give an option to the user to select 'Customer Mail ID' dynamically and see the column to be displyed in the report along with the existing columns.
    Through 'Column Selector' user can select a single column at a time, but if he want to select more than one column, how can we do this ?
    Please help me out in resolving this issue.
    Thanks,
    Chaithanya.

    Hi Chaithanya,
    there's not a straight solution for this. You can create different analysis containing different number of columns and then directing the user to this analysis using Action Links or you can also use View Selector to switch from one view (analysis) to the other. But it's not going to be very flexible nor dynamic.
    J.

  • Dynamic lenght in report heading

    Hi experts,
    I need to pass dynamic length in report heading.
    i.e.., REPORT zrep LINE-SIZE dyn_len NO STANDARD PAGE HEADING.
    So that my report output width will be in different length based on value dyn_len.
    Any solution or alternative in simple list display. Pls suggest ....
    Thanks in advance.
    Zak.

    Hello,
    Do not specify LINE SIZE in that case.
    Thanks,
    Jayant

  • Dynamic Sql In Report

    Hello
    Can i use dynamic sql in report builder , so as to allow user-defined reports .
    Thanx
    Shrikant

    read in the help system about lexical variables (these are variables with & at the begining).
    So you can define a query as select &P_1 where you get P_1 as a parameter.

  • How to create  some columns dynamically in the report designer depending upon the input selection

    Post Author: ekta
    CA Forum: Crystal Reports
    how  to create  some columns dynamically in the report designer depending upon the input selection 
    how  export  this dynamic  report in (pdf , xls,doc and rtf format)
    report format is as below:
    Element Codes
    1
    16
    14
    11
    19
    10
    2
    3
    Employee nos.
    Employee Name
    Normal
    RDO
    WC
    Breveavement
    LWOP
    Sick
    Carers leave
    AL
    O/T 1.5
    O/T 2.0
    Total Hours
    000004
    PHAN , Hanh Huynh
    68.40
    7.60
    76.00
    000010
    I , Jungue
    68.40
    7.60
    2.00
    5.00
    76.00
    000022
    GARFINKEL , Hersch
    66.30
    7.60
    2.10
    76.00
    In the above report first column and the last columns are fixed and the other columns are dynamic depending upon the input selection:
    if input selection is Normal and RDO then only 2 columns w'd be created and the other 2 fixed columns.
    Can anybody help me how do I design such report....
    Thanks

    Hi Developer life,
    According to your description that you want to dynamically increase and decrease the numbers of the columns in the table, right?
    As Jason A Long mentioned that we can use the matrix to do this and put the year field in the column group, amount fields(Numric  values) in the details,  add  an filter to filter the data base on this column group, but if
    the data in the DB not suitable to add to the matrix directly, you can use the unpivot function to turn the column name of year to a single row and then you can add it in the column group.
    If there are too many columns in the column group, it will fit the page size automatically and display the extra columns in the next page.
    Similar threads with details steps for your reference:
    https://social.technet.microsoft.com/Forums/en-US/339965a1-8cca-41d8-83ef-c2548050799a/ssrs-dataset-column-metadata-dynamic-update?forum=sqlreportings 
    If your still have any problem, please try to provide us more details information, such as the data structure in the DB and the table structure you are currently designing.
    Any question, please feel free to let me know.
    Best Regards
    Vicky Liu

  • RE:calculated Average Valuated Stock Value

    Hi ALL,
    how to calculated Average Valuated Stock Value  logic (The sum of the daily stock value for the time frame of the analysis divided by the number of days) please guide me.
    regards,
    ravi

    Please ...........................
    guide me.......................
    how to created formula for this logic
    (The sum of the daily stock value for the time frame of the analysis divided by the number of days)
    Regards,
    ravi

  • How to consider only values 0 when calculating Averages

    Hi,
    Currently, I am using Avg (table.column) function to caluclate averages. However, one of our user wants to only consider records that are >0 when calculating averages. For example if a result set as 10 records, and only 2 of them has values >0 then typically Avg function would caculate based on (sum of 10 records/10). But per our user's requirement, he wants to consider (sum of 2 records/2) and ignore the remaining 8.
    Can you please tell me how to do achieve this?

    I found the solution after much deliberatiion myself :-). I used the following formula instead of the AVG function and it worked.
    Note that "Fact - +fact name+".column is a numeric column and can have null values.
    SUM(IFNULL("Fact - +fact name+".column, 0)) / COUNT("Fact - +fact name+".column)

  • How to spilt columns dynamically in the report based on Date Parameters

    Hi All,
    We have an XML Publisher report in which the parameters are Fom date and To date.
    User wants the data in the report to be split dynamically based on the months in the From date and To date interval.
    Eg. if the From date is 01-JAN-2013 and To date is '31-MAR-2013' then the report should show 3 columns JAN,FEB and MAR and the corresponding data.
    if the From date is 01-JAN-2013 and To date is '31-MAY-2013' then the report should show 5 columns JAN,FEB,MAR,APR and MAY and the corresponding data.
    Can anyone please advise, how can we spilt the months and data dynamically in the report.
    Regards,
    Shruti

    well you wanted the columns to be added dynamically.  the easiest way would be to use a Pivot since the columns are based on the values in the data.  and if the values of that column are Month Name/Abbreviation for that date then you will get month columns.
    Have you worked with Pivots before?

  • Dynamic Queries in reports 6i

    Hi, I was wondering if its possible to build a dynamic query on reports 6i. on the report wizard I cant get a user parameter...
    here is what im trying to do: I have a query where the fileds am retrieving are always the same, what its going to change is the where clause, it can be like betwwen 2 different dates ot it also could be a lot of ORs, like, Company_ID = 1 or Company_ID = 2 and such.
    Thanks

    yes, the thing is when I build the query on the report wizard it goes like this:
    select field1,field3, field4 from Table
    where p_clause
    so I get an error, and the query cannot be build like that, it says ORA-00920 invalid relational operator Where p_clause ==>
    So I thing my problem basically is how to build the query... any idea on how to do it? thanks
    can you explain me how this After Parameter works a little bit more
    Edited by: user10798811 on Mar 24, 2009 1:11 PM

  • Change image size dynamically in BIP report

    Can we change the size of image dynamically in bip report. If yes can I get some doccument or samples on it.
    Thanks
    Aj

    I am doing small POC
    I have a rtf template with three sample images on it with three different sizes for 1” by 1” , 3” by 3” and 5” by 5”.
    I have a standard size of 2” by 2” image in my server (Could change size in future depending on req)
    Now when I run the report the template should call the standard image from server and replace the sample images on the rtf and show the the standard image in three different sizes.
    Pls let me know if i am missing something

  • Adding the columns dynamically in crystal report

    Hi,
      I am developing a application using asp.net and crystal report. In a report the column is created dynamically( ie, the report gets input from a sp which returns N no. of columns). Since i dont know the column name and no. of columns at design time i am not able to create the report. If any of you have any idea on adding the columns dynamically please send me the code or the link.
    Thanks
    Sankar

    Hello Sankar,
    please see CS code for VS 2005 below to add a database field to a report using inproc RAS.
    This sampels retrieves the table column name from the database and adds it to the report.
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.ReportAppServer.Controllers;
    using CrystalDecisions.ReportAppServer.ClientDoc;
    using CrystalDecisions.ReportAppServer.DataDefModel;
    namespace CS_Add_Field_inproc
        public partial class Form1 : Form
            // CR Declarations
            ReportDocument boReportDocument;
            ISCDReportClientDocument boReportClientDocument;
            CrystalDecisions.ReportAppServer.ReportDefModel.Section boSection;
            CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject boFieldObject;
            public Form1()
                InitializeComponent();
                //Create a new ReportDocument
                boReportDocument = new ReportDocument();
                // load the RPT file
                boReportDocument.Load("..
    AddField.rpt");
                //Access the ReportClientDocument in the ReportDocument (EROM bridge)
                boReportClientDocument = boReportDocument.ReportClientDocument;
                //Get the first section in the details section
                   boSection = boReportClientDocument.ReportDefController.ReportDefinition.DetailArea.Sections[0];
                   //Create the field object that we will add to the report and set all of its properties
                   boFieldObject = new CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject();
                //Set which field to use for the data to be displayed
                   boFieldObject.DataSourceName = "{Customer.City}";
                   boFieldObject.FieldValueType = CrystalDecisions.ReportAppServer.DataDefModel.CrFieldValueTypeEnum.crFieldValueTypeStringField;
                   boFieldObject.Left = 4 * 1440; //1440 twips per inch
                   boFieldObject.Width = 3 * 1440;
                   boFieldObject.FontColor = new CrystalDecisions.ReportAppServer.ReportDefModel.FontColor();
                   boFieldObject.FontColor.Font.Name = "Arial";
                   boFieldObject.FontColor.Font.Size = 10;
                   boFieldObject.Format.HorizontalAlignment = CrystalDecisions.ReportAppServer.ReportDefModel.CrAlignmentEnum.crAlignmentLeft;
                   //Add the object to the report
                   boReportClientDocument.ReportDefController.ReportObjectController.Add(boFieldObject, boSection, -1);
                // show in reportviewer
                crystalReportViewer1.ReportSource = boReportDocument;
            private void button1_Click(object sender, EventArgs e)
                //Get the first section in the details section
                boSection = boReportClientDocument.ReportDefController.ReportDefinition.DetailArea.Sections[0];
                //Create the field object that we will add to the report and set all of its properties
                boFieldObject = new CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject();
                //Set which field to use for the data to be displayed
                boFieldObject.DataSourceName = "{Customer.City}";
                boFieldObject.FieldValueType = CrystalDecisions.ReportAppServer.DataDefModel.CrFieldValueTypeEnum.crFieldValueTypeStringField;
                boFieldObject.Left = 4 * 1440; //1440 twips per inch
                boFieldObject.Width = 3 * 1440;
                boFieldObject.FontColor = new CrystalDecisions.ReportAppServer.ReportDefModel.FontColor();
                boFieldObject.FontColor.Font.Name = "Arial";
                boFieldObject.FontColor.Font.Size = 10;
                boFieldObject.Format.HorizontalAlignment = CrystalDecisions.ReportAppServer.ReportDefModel.CrAlignmentEnum.crAlignmentLeft;
                //Add the object to the report
                boReportClientDocument.ReportDefController.ReportObjectController.Add(boFieldObject, boSection, -1);
                // show in reportviewer
                crystalReportViewer1.ReportSource = boReportDocument;

Maybe you are looking for

  • Problem with breakpoints in Web Dynpro components

    Hello experts, I have problems with breakpoints in methods of Web Dynpro components. Sometimes everything works as expected and a new window with the debugger comes up. Sometimes the breakpoints are ignored, and debugging is impossible. It even happe

  • Error in Generating Absense Quota - PT60

    Hi Experts, When I am running the PT60 to generate absence quota, i am getting an error msg no data in table T001P i have checked the grouping values as well, still i am not able to generate. kindly give ur inputs Appreciate your early response. Rega

  • Adobe 12 elements keeps asking my to sign in on my macbook pro? help

    adobe 12 elements keeps asking my to sign in on my macbook pro? help

  • View image from local

    Hi, I'm using J2ME wireless toolkit, and I want to know is it possible to view image from local(eg. C:\WTK22\appdb\DefaultColorPhone\filesystem\root1). I've written some code to view form the folder but it appear "error: null". mage storedImage = nul

  • Help! Messed up on alignment.

    http://www.ivoog.com/link Yeah...I kind-of messed up what I was working on and need some help. See the two boxes on the left? How can I make it so all the stuff under those two boxes will be to the right of the two boxes. So I need it to look somethi