How to calculate query value on extended range of data

Hi,
This is my first post, so let me greet all forum users. I'm reading the forum for few weeks and I'm really impressed with the force of this community.
My question is based on some real problems but I'll ask in general:
In a BEx query - is it possible (and how?) in a result cell to obtain value that is calculated based on some more extended range of infoprovider records than it results from all the characteristics related to that cell?
The question is somehow about a reverse case to the restriction in Selection. I'm asking about a kind of 'extension' of selection.
Example for the question follows (it is somehow simple, I put it here just to picture the problem, note: the question is more general!)
cube: ch: 0CALMONTH, 0MATERIAL, 0PLANT
      kf: 0QUANTITY (ex. of outgoing deliveries)
What I need is to obtain in any query the SUM(0QUANTITY) over all 0PLANT (this can lead to knowing the 'activity' of the specific plant by calculating the share. that activity can be calculated at diferent level of detail).
The 'dream' query would look like:
rows: 0CALMONTH, 0MATERIAL, 0PLANT      
cols: 0QUANTITY  SUM_OVER_0PLANT
resulting in ex:
0CALMONTH  0MATERIAL  0PLANT  0QUANTITY  SUM_OVER_0PLANT  PLANT_ACTIVITY
2005.01    00001      P100    10         30               1/3
2005.01    00001      P200    20         30               2/3
2005.01    00002      P100    30         70               3/7
2005.01    00002      P200    40         70               4/7
2005.02    00001      P100    50         110              5/11
2005.02    00001      P200    60         110              6/11
2005.02    00002      P100    70         150              7/15
2005.02    00002      P200    80         150              8/15
after removing drill 0MATERIAL:
0CALMONTH  0PLANT  0QUANTITY  SUM_OVER_0PLANT  PLANT_ACTIVITY
2005.01    P100    40         100              4/10
2005.01    P200    60         100              6/10
2005.02    P100    120        260              12/26
2005.02    P200    140        260              14/26
after removing drill 0CALMONTH:
0PLANT  0QUANTITY  SUM_OVER_0PLANT  PLANT_ACTIVITY
P100    160        360              16/36
P200    200        360              20/36
For this specific case I investigated several solutions:
1) using formula & function SUMCT (Result). This has a drawback that Result for 0PLANT must be present in right place (bottom level) in the resulting query. I don't like this.
2) SUM can be directly precalculated in the cube. Well, I'd prefer Bex only...
Please keep in mind also following:
1) there may be a need to refer to the data that is outside prompt/filtering/restricting range.
2) I want to preserve all the OLAP freedom, so all the solution should be a query with some tricky formula/kf/??? to be used by user in any situation and producing right result.
I hope I'm not demanding to much...
(now after this long example please have a look at the question again!)
Regards,
Mirek

Hi Ashwin,
while using SUMCT I loose the freedom of OLAP. SUMCT calculates properly SUM_OVER_0PLANT only when the 0PLANT is the lowest drillin level. If this is not the case (ie. some other ch is the lowest level or 0PLANT results are suppressed) the approach won't provide right result.
sure I will reward all helpfull posts.
regards,
Mirek

Similar Messages

  • How to calculate acquisition value for specified day

    Hi,
    in my z program I have a problem how to calculate acquisition value for my asset for specified day.
    Example:
    I have asset created 8.7.2008 with TTYPE 104 (External asset acquisition) with value 5950.
    30.11.2008 there is another TTYPE 272 (Retirement of current-yr acquis., w/o revenue) with value 950.
    So BEFORE 30.11.2008 acquisition value is 5950. After is 5000. Is there any function module (or something else) in SAP system where I can send asset number and date a it return to me acquisition value for that day?
    Many thanks for any answer!

    Hi,
    your suggestion means that I have to compute acquisition value by myself (sum all TTYPE 1** - sum all TTYPE 2**). So SAP does't provide such functionality (LDB ADA have it, because it can compute acquisitiob value for specific day)?
    Mant thanks for answer

  • How to assign attribute values to a range of BPs ????

    Hi All,
         While assigning attribute values to business partners we can specify at the most one business partner at a time.
    My requirement is to assign attribute values to a range of business partners at a time.
    Is there any customization setting where I can do this OR
    do I write a report for this ?
    Regards,
    Ashish

    Hi Ravi,
          Thanks for replying !!!!
    But, CRMD_MKT_TOOLS doesnt seem to solve my problem.
    I have a range of BPs (e.g 8000101 to 8000199).
    And I have a list of attribute sets with values as follows:-
    Attribute Set            Values
    Age group                1 - 10, 11 - 20, ....
    Reading habits          Business, sports, news.....
    Profession                Doctor , Engineer .......
    and so on..
    Now in transaction CRMD_PROF_BP, I can choose a single BP (e.g. 8000101) and assign it an attribute set(e.g. Profession) and value (Doctor).
    But, my requirement is to specify an entire range of BPs(8000101 to 8000150) and assign attribute set and values to that entire range.
    Now how do I achieve this ???????
    (target groups would be created only after attributes have been assigned)
    Regards,
    Ashish

  • How to set Query value in WAD w. parameters

    Hi
    Is it possible to set the queryname in the dataprovider using javascript.
    My scenario is that I want to fetch the queryname from the URL with the following javascript
    I have the script:
    function GetPara( name )
         name = name.replace(/[\[]/,"
    \[").replace(/[\]]/,"
         var regexS = "[
    ?&]"name"=([^&#]*)"; 
         var regex = new RegExp( regexS ); 
         var results = regex.exec( window.location.href ); 
         if( results == null )   
              return ""; 
         else   
              return results[1];
    And then I want to implement something like the following in the template
    //First dataprovider (TAB_A_DP) initialization
    <bi:QUERY_VIEW_DATA_PROVIDER name="TAB_A_DP" >
                    <bi:INITIAL_STATE type="CHOICE" value="QUERY" >
                        <bi:QUERY value="SCRIPT_FUNCTION">
                               <bi:SCRIPT_FUNCTION value="GetPara('TAB1')" />
                        </bi:QUERY>
                    </bi:INITIAL_STATE>
                </bi:QUERY_VIEW_DATA_PROVIDER>
    //SEcond dataprovider (TAB_B_DP) initialization
    <bi:QUERY_VIEW_DATA_PROVIDER name="TAB_B_DP" >
                    <bi:INITIAL_STATE type="CHOICE" value="QUERY" >
                        <bi:QUERY value="SCRIPT_FUNCTION">
                               <bi:SCRIPT_FUNCTION value="GetPara('TAB2')" />
                        </bi:QUERY>
                    </bi:INITIAL_STATE>
                </bi:QUERY_VIEW_DATA_PROVIDER>

    Hi Leo
    Sorry I haven't explained my goal very well.
    I want to create a dynamic webtemplate w. two tabs. One tab showing data from one dataprovider and the other tab showing data from another dataprovider.
    My problem is that it's easy enough to set the dataprovider to a specific query but as I have several reports which should use this template then instead of coping the template and change the query name I want a generic way to set the queryname  (e.g. in the url) so I only have one template and not a template per report pair.
    In short I want to set the Initial State dynamic.
                                <bi:QUERY_VIEW_DATA_PROVIDER name="TAB_A_DP" >
                                    <bi:INITIAL_STATE type="CHOICE" value="QUERY" >
                                        <bi:QUERY value="dynamic" text="dynamic" />
                                    </bi:INITIAL_STATE>
                                </bi:QUERY_VIEW_DATA_PROVIDER>
    When I only have one dp I can leave it empty and set the query by typing ?query=<queryname> but what if I have several dataproviders with different queries?
    /John
    Edited by: John Dolph on Aug 26, 2009 3:22 PM

  • How to calculate usage value through measuring document.

    Hi,
    While creating Sales Order with reference to a Contract i need to update the usgae value in the Order Quantity ( RV45A-KWMENG ) field (at line item level).
    Can you help me calculate usage value through measuring documents for equipment over a period of time.
    Is there any function module for the same?
    Thanks.

    Hi,
    To determine the usage value of a an equipment I had followed the following.
    From table STPO, check if the material receipted belongs to a standard BOM (STLTY='S')
    If yes, record the BOM (STLNR)  and the BOM item node number (STLKN)
    From PLMZ table, select the task list type (PLNTY), the key for task list group (PLNNR), the group counter (PLNAL), the task list node number for operation (PLNKN),   if the record is not flagged for deletion (LOEZ)
    From PLFH table, select the object type of the CIM resource (OBJTY), the object id of the resource (OBJID), the usage value (EWVGW) if the record is not flagged for deletion (LOEZ)
    From CRVE_A table, select the equipment number (EQUNR)
    The result of this selection will be all the tools which can be used for the production of the material receipted.
    The measuring point for this or these equipment(s) will be selected from equipment number and EQUI table
    The result of this selection will be all the measuring point to update.
    Create new measurement document for the selected measurement point (transaction IK11)
    Technically go as follows:-
    MAT = material receipted
    Select STLY, STLNR, STLKN from STPO table where IDNRK='MAT' and STLTY='S'
    If results exist
    Select STLTY, PLNNR, PLNAL, PLNKN from PLMZ where PLMZ.STLTY=STPO.STLTY and PLMZ.STLNR=STPO.STLNR and PLMZ.STLKN=STPO.STLKN
    And PLMZ.LOEZ<>'X'
    Select EWVGW, OBJTY, OBJID from PLFH twhere PLFH.STLTY=PLMZ.STLTY and PLFH.PLNNR=PLMZ.PLNNR and PLFH.PLNAL=PLMZ.PLNAL and PLFH.PLNKN=PLFH.PLNKN and PLFH.LOEKZ<>'X'
    USAGE=PLFH.EWVGW
    Select EQUNR from CRVE_A where CRVE_A.OBJTY=PLFH.OBJTY and CRVE_A.OJBID=PLFH.OBJID
    All the equipment number selected at this moment will be called EQUIP in the next steps
    EQUIP= Equipment number previously selected
    Select OBJNR from EQUI where EQUNR=EQUIP
    Select PARNR from IHPA where OBJNR=EQUI.OBJNR
    If PARNR = Vend then
    Select IMRC_POINT from equi where equnr=equip
    All the measuring points  selected at this moment will be called MEASP  in the next steps
    For each MEASP
    Insert into IMRG the new increment value  (USAGExMAT) in field CDIFF
    Remark: the field CDIFF is managed in floating point number, accurate to 8 bytes.
    I hope this is useful for you.
    Regards,
    Ankur Parab

  • How to Calculate AGE by getting difference between two Date Fields

    HI Gems
    I need to calculate AGE from getting difference from two date fields. But when i am trying to wrte fromula as Current date - date1(some date field) then it is showing error.
    How can i get values.
    Thanks
    Manu

    You already asked this question:
    How to calculate AGE from two different date fields

  • How to calculate YTD and Last year YTD on Date in Bex

    Hi,
    I have a requirement in which I need to show the report as following format.
    I need to show    Year>monthday as Hierarchy. user will drill down on Month to Date.
                 Del Qty              Ord Qty              Del  Qty LY              Del Qty YTD                  Del Qty  L YTD
    Year
    > Drill Down to Months
            Jan
            Feb
            Mar
              ---> 1.03.2010
              ---> 2.03.2010
              ---> 3.03.2010
            Dec
    I have Calday, Calmonth, Calyear all three objects.
    Now my question is how I can achive this? On which i need to create hierarchy?
    and how to calculate the YTD at day level.
    Note:- in the selection calyear is mandatory. User wants to display as per year.   So What infoobject I need to take in selection?
    and the way to calculate YTD on Day (in the case also ,where user doesn't give the date in selection)
    Plz reply asap its uregent !!!
    Thanks in advance,
    Amit

    Hi,
    As per my understanding I think YTD means JAN to current date result. I means say if user enter 062005 then result in YTD should be from 012005 to 062005.
    And to do this you need to write a customer exit variable where LOW field of internal table you will put JAN year and HIGH will contain month year entered by user.
    Hope this will help you.
    Suneel

  • How to generate SIDs for a particular range of data for a DSO ?

    Hi All,
    Please let me know if there is any way to generate SIDs for a particular range of data for a DSO which does not have any SID values. I need this as when i am trying to load data from DSO to InfoCube it's taking a lot of time. When i tried to find the reason behind it, i came to know that most of the time is going in SID creation for the data which is getting loaded. Please share some solution for the same. Thanks...

    Hi,
    Try this.
    Create an internal table and populated it with the values present in the F4 help of the field. Then in AT SELECTION-SCREEN event check the value of the field with the values in the internal table and display the appropriate message.
    Sharin.

  • How to calculate the partition size in range partition,by value

    hi all,
    The primary key is number for the table.
    I have 5543201 records in a table.
    If I want to break them in 7 equal partition as per the primary key,how do i achieve this?
    rgds
    s

    I probably don't understand it...but I would say:
    5543201/7=791886
    range 1 : 0....791886 (1x 791886)
    range 2 : 791887....1583772 (2 x 791886)
    range 3 : 1583773 .... (3 x 781886)
    tange 4 : ......
    HoweverI doubt whether this is a smart aproach for partitioning.
    I would say that a patitioning on date, or some key-value is more applicable.
    But hey...I don't know the further requirements.
    Cheers Martijn

  • How to calculate avg value in bex

    Hi all
    I have a requirement
    I want to run a query for a particular period say 0032005.
    in the query output value will display for all prior period in different column. for perod 003
    it will display value for 001 , 002 ,003. and
    at the last column  i want calculate the avarage for this 3 period. these should be dinamic.
    if i run this query for period 0052005. query will display value for period 001 ,002 ,003,004,005 and last column will display avarage for the 5 period.
    i am able to diaplay each prior period in different column that is fine. but i am not abel to calculate the avarage column.
    example
    selection screen :
    fiscal period : 0042005
    Query output
    Char 0012005 0022005 0032005 0042005   Avg
         88        99     77       66     (889977+66)/004
    Please any one know about please help with steps.
    Thanks

    I have a requirement
    I want to run a query for a particular period say 0032005.
    in the query output value will display for all prior period in different column. for perod 003
    it will display value for 001 , 002 ,003. and
    at the last column i want calculate the avarage for this 3 period. these should be dinamic.
    if i run this query for period 0052005. query will display value for period 001 ,002 ,003,004,005 and last column will display avarage for the 5 period.
    i am able to diaplay each prior period in different column that is fine. but i am not abel to calculate the avarage column.
    example
    selection screen :
    fiscal period : 0042005
    Query output
    Char 0012005 0022005 0032005 0042005 Avg
    88 99 77 66 (889977+66)/004
    I got the resolution as bellow.
    In the Characteristic Property Set it as Suppress Result Rows-> Never. For the key figure Set Calculate Result Rows-> Average of All Values.
    yes it is working fine . but there is a small problem in the column heading for this colume is displying as overall result. but values are displying as a avg value. how can i change it.
    why i ahve to create a text variable. please explain

  • How to get all values in the range of select option into internal table?

    Hi,
    I need to capture all entries coming in the range of select option into one internal table.
    How to do get that?
    For E.g
    select-options: matnr for mara-matnr.(select option)
    IF I enter G0100013507892 as lower value of matnr and G0100014873947 as higher value
    and if there are 10,000 materials in the above range, then I want to capture all theses 10000 materails in one internal table. How to do that?
    Regards,
    Mrunal

    Hello Mrunal Mhaskar  ,
    What i understand you can do one thing  go in debug mode
    Try this code : -
    LOOP AT s_matnr_ex.
      IF s_matnr_ex-low IS NOT INITIAL.
        i_matnr-matnr = s_matnr_ex-low.
        i_matnr-option = s_matnr_ex-option.
        APPEND i_matnr.
        CLEAR : i_matnr.
      ENDIF.
    ENDLOOP.
    LOOP AT s_matnr_ex.
      IF s_matnr_ex-high IS NOT INITIAL.
        i_matnr-matnr = s_matnr_ex-high.
        i_matnr-option = s_matnr_ex-option.
        APPEND i_matnr.
        CLEAR : i_matnr.
      ENDIF.
    ENDLOOP.
    In the i_matnr table high and low values are there.
    Regards,
    Vandana.

  • How can I use AirportExtreme to extend range of iMac based AirportNetwork ?

    I've read a lot of infomation about using Airport Extreme or Express to extend a network that has an Airport Extreme base station as its 'hub' via WDS, but nothing about the case where the 'hub' (that creates the network and is connected to the internet) is not a base station, but a computer.
    I have a cable modem connected directly (Ethernet) to my iMac G5. My MacBookPro can connect to the internet via an Airport network created by the iMac, but i need to extend the range of this. A friend has given me an Airport Extreme that he isn't using and I have spent all day trying to get it to connect to the iMacs network ... to act as a 'relay', but can't see how to do it.
    (I can get the iMac, and MacBookPro to connect to a network created by the Airport Extreme with no problems, but not the other way round) .... Please help, i'm going crazy with this !
    Many Macs/ Many OS's     desperate
    Many Macs/ Many OS's    

    Hi SGIII,
    I just wanted to say thanks for kick starting me. I am well on my way to accomplishing this task with some modifications to the Applescript source you provided. I figured out that I would need to loop through the input and lookup each individual character in the dictionary (so I created a separate service to handle simple dictionary lookup). I parse the definition using your suggested code wrapped into a function, and then append the output. Right now it's close but not perfect: showing this output for the characters above:
    "wǒshìAměiAguórén" (the A is wrong and the reason is that I need to change the delimiter to factor that some definitions will have a capital A in them). I will share the finished script on my pastebin.
    ----on run {input, parameters}
    set my_string to "我是美国人" --input
    set output to ""
    repeat with counter_variable_name from 1 to count of my_string
      set current_character to item counter_variable_name of my_string
      set current_definition to do shell script "automator -i " & current_character & " ~/Library/Services/GetChineseDefinition.workflow"
      set output to output & parseForPinyin(current_definition)
    end repeat
    --end run
    on parseForPinyin(character_input)
      set pyCharSet to {"a", "ā", "á", "ǎ", "à", "b", "c", "d", "e", "ē", "é", "ě", "è", "f", "g", "h", "i", "ī", "í", "ǐ", "ì", "j", "k", "l", "m", "n", "o", "ō", "ó", "ǒ", "ò", "p", "q", "r", "s", "t", "u", "ū", "ú", "ǔ", "ù", "ǖ", "ǚ", "ǜ", "w", "x", "y", "z"}
      set {oTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "①"}
      set cc to (character_input as string)'s text items's item 1's characters 2 thru -1
      set py to ""
      repeat with c in cc
      if c is in pyCharSet then set py to py & c
      end repeat
      set AppleScript's text item delimiters to oTID
      return py
    end parseForPinyin
    The GetChineseDictionary Service couldn't be simpler:

  • How to calculate mean value of a matrix

    Hi... I ve one matrix of order (m*n). I need to calculate the mean value of this matrix. How to do this?
    let we consider the matrix as 4x4.(Row=Column=4) The resultant matrix i.e mean value matrix is 1x4(Row=4,Column=1). To read the row value simultaneously in order to calculte the mean value thro row.... ?  please help me out
    Example:
    Matrix A=1 2 3 4
                   5 6 7 8
                   1 3 5 7
                   2 4 6 8. 
    Mean value thro row would be:   10/4 [  (1+2+3+4)/4
                                                      26/4 [ (5+6+7+8) /4...Like this i ve to do..
    Please help me out

    Hi,
      See this attachment.....
    Thanks and regards,
    srikrishnaNF
    Attachments:
    Example_VI_BD.png ‏3 KB

  • How to calculate the values

    Hi Experts,
    I have doubt, i have an internal table now i want to calculate the total for every group. How to do that?
    value          type
    5,439.01 ;    ZMP0
      509.60 ;     ZMP0
    4,749.26 ;    ZMP0
    9,053.95-    ZPNL
    732.70-      ZPNL
    66.30-       ZPNL
    18.10-        ZS03
    63.90 ;        ZS03
    According to the type i need a total for ZMPO, ZPNL, ZSO3 separately.
    how to do that?
                       5,439.01 ;    ZMP0
                         509.60 ;     ZMP0
                        4,749.26 ;    ZMP0
    ZMPO total =
                         9,053.95-    ZPNL
                          732.70-      ZPNL
                           66.30-       ZPNL
    ZPNL total =
                          18.10-        ZS03
                           63.90 ;        ZS03
    ZSO3 total =
    Like that i need, can any one help this?
    Regards,
    Mohana

    Hello,
    Use the COLLECT.
    DATA:
      wa LIKE LINE OF itab,
      itab_sum LIKE itab.
    SORT itab BY key.
    LOOP AT itab INTO wa.
      COLLECT wa INTO itab_sum.
    ENDLOOP.
    The itab_sum has the same structure like the itab where is the data to me summarized, and the wa has the line structure of the itab.
    Regards.

  • How to calculate average value?

    Hi all,
    I'm using Lumira 1.15. I'm doing some practices with the sample dataset BestRunCorp... I want to calculate the average value of gross margin which is grouped by lines so that I can use a line chart to show the difference between the gross margin value and average value.
    How can I achieve this ?
    Best regards,
    Shuang

    It looks like it calculates the average based on the dimension
    See below:
    If you take the "Best run" Excel file, sort by country, calculate the average in Excel, it matches Lumira's 4,056 (for Argentina)
    I am not sure I follow your divide by 12 logic?

Maybe you are looking for

  • Problems with pages and mail merging from Address Book

    hey guys. I have just created an invitation using one of the templates in Pages. this template is for four postcard size invites on one sheet of A4. i want to merge addresses from my address book. i can do the merge except that rather than four diffe

  • Add prefix to file names using AppleScript

    Hello, I'm trying to write a script that when ran, will add the prefix "R" to all file names within a folder called "1 Reverse Footage". I've tried two different scripts (below) and they aren't working. Any help is much appreciated! 1st attempt prope

  • Error on loadjava with log4j

    Hi. I have a problem loading jar file: oracle 9.2.0.7.0 on unix server with jvm 1.3.1 Using sqlplus I didn't receive any error (PL/SQL procedure successfully completed.) on loading log4j-1.2.14.jar with the following command 6 java class (org/apache/

  • Best practices using IronPort

    This section is to share real-world stories about how folks have configured their IronPorts. What really works (or doesn't) out there in the IronPort Nation?

  • Webservices: Error trying to run web services.

    Hi All, I am trying to run a webservice that has been created with jdeveloper, this is what i did, -Create my WS Class -Right click over that class and choose the option "Create Web Service". -Click next in all displays(Default Options). All compile